Qbasicnews.com
picture encryption - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: picture encryption (/thread-9326.html)

Pages: 1 2 3


picture encryption - Dio - 05-30-2006

no, i mean how to upload picture into FB so that while in the fb program i see the image from the bmp displayed on the screen. and, if i want, save the bmp back onto my computer in a new file or, if i wish, save over the file that i drew the bmp from in the first place.


picture encryption - Dio - 05-30-2006

and, if possible, have the computer detect the dimension (that means how big the picture is) automatically.


picture encryption - Anonymous - 05-30-2006

Code:
bload "mybmp.bmp"

dim as integer bmp_x, bmpy
dim as any ptr bmp_img

bmp_img = imagecreate( bmp_x, bmp_y )

get( 0, 0 )-( bmp_x - 1, bmp_y - 1 ), bmp_img

bsave "mynewbmp.bmp", bmp_img


i believe thats how. you can also skip a step

Code:
dim as integer bmp_x, bmpy
dim as any ptr bmp_img

bmp_img = imagecreate( bmp_x, bmp_y )

bload "mybmp.bmp", bmp_img

put( 20, 20 ), bmp_img

bmp_x and bmp_y would of course contain the dimensions of the image


picture encryption - Dio - 05-31-2006

cool thanks. Smile


picture encryption - Kylemc - 06-01-2006

Why not just encrypt the BMP or whatever file instead of messing around with the individual pixels?


picture encryption - Dio - 06-01-2006

i thought about this for awhile and the came to a simple answer:








i don't know how.


picture encryption - marinedalek - 06-01-2006

Just to add more shortening to the much debated ( :winkwink: ) code...
Code:
pset (x,y), point(rx,ry)
pset (rx ,ry), point(x,y)



picture encryption - Neo - 06-01-2006

Quote:Just to add more shortening to the much debated ( :winkwink: ) code...
Code:
pset (x,y), point(rx,ry)
pset (rx ,ry), point(x,y)
That won't work. You'll put the same color back, instead of swapping the colors. :winkwink:


picture encryption - Anonymous - 06-01-2006

...and lose the color at x, y in the process >.>


picture encryption - Zack - 06-01-2006

Code:
#define infile "infile.bmp"
#define passfile "passfile.bmp"
#define outfile "outfile.enc"
dim as integer ifHandle,pfHandle,ofHandle,fpos
dim as ubyte ifTemp,passTemp
ifHandle=freefile
pfHandle=ifHandle+1
ofHandle=pfHandle+1
open infile for binary as #ifHandle
open passfile for binary as #pfHandle
open outfile for binary as #ofHandle
if lof(ifHandle)<>lof(pfHandle) then
    print "Error: different file lengths."
    sleep
    end
end if
do
    get #ifHandle,,ifTemp
    get #pfHandle,,passTemp
    put #ofHandle,,chr$(ifTemp xor passTemp)
    fpos+=1
    if fpos>=lof(ifHandle) then exit do
loop
print "Done."
sleep
close
There's a simple encryption app. Infile is the file you want to encrypt, passfile is the password file, and outfile holds the name of the encrypted file you want to create. Infile has to be EXACTLY the same size as passfile, otherwise it won't work (using a password the same length as the data to encrypt makes the code theoretically unbreakable). To decipher, put whatever outfile you used in the infile field, use the original passfile, and make up a name for the new, unciphered file.
If you are encrypting a bitmap file, make a password file by just opening up mspaint and drawing a picture that has the exact same dimensions of the picture you want to encrypt. (Note: that won't work for some compressed image formats like png, because even two pictures of the same dimensions will have different compressed sizes.)