Dio
|
 |
« on: May 26, 2006, 06:32:51 PM » |
|
(ironically zach just created an encryption thread) i'm working on a picture encryption program where all of the pixels would be jumbled. i'm not to sure how original my little idea is, but the program would work like this: you load a picture and enter a password (well, passnumber) and that number would get plugged into the random number generator like this: RANDOMIZE (number) then the program would go pixel by pixel: for y = 0 to ymax for x = 0 to xmax and pick a random number between 0 and the max x/y of the picture. and swap the x,y with the "random" rx,ry. now this isn't truly random, because you would know the seed number. so going backwards you could re-organize the original order of the pixels. if you don't understand (i don't blame you) look at what i have here: (and yes i'm aware i have a FOR...NEXT delay in there but i swear it's for debugging purpose only!) screenres 320,200,32,2,1 input "Pass "; p# for y = 0 to 99 for x = 0 to 99 c = c + int(16777216 / (100*100)) pset (x,y),c next next sleep ymax = 99 xmax = 99 randomize p# for y = 0 to ymax for x = 0 to xmax rx = int(rnd*xmax) ry = int(rnd*ymax) pa = point(x ,y ) pb = point(rx,ry) swap pa, pb pset (x ,y ),pb pset (rx ,ry ),pa line (-1 ,-1 )-(100,100),0,b pset (100,y ),16777215 pset (x ,100),16777215
for sa = 0 to 2000000:next next next sleep end The problem is the pixels aren’t getting swapped. and i just know the answer is right under my nose
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Neo
|
 |
« Reply #1 on: May 26, 2006, 06:40:29 PM » |
|
You have: pa = point(x ,y ) pb = point(rx,ry) pc = pa pa = pb pb = pc pset (x ,y ),pb pset (rx ,ry ),pa (You're putting the same number back in the same position, because you swap them twice) Use: pa = point(x,y) pb = point(rx,ry) Swap pa, pb pset (x,y),pa pset (rx ,ry),pb It might work... ^^ Yours, - Neo
|
|
|
Logged
|
|
|
|
Dio
|
 |
« Reply #2 on: May 26, 2006, 06:47:57 PM » |
|
well actully, i just did that (i rembered seeing a swap function and i just now figured out how to use it) but still no avail. thanks though! 
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Neo
|
 |
« Reply #3 on: May 26, 2006, 06:49:25 PM » |
|
I will post the differences again, fat code is changed code. pa = point(x,y) pb = point(rx,ry) Swap pa, pb pset (x,y),pa pset (rx ,ry),pb I should've done this before. (And you might have done better by copying my code next time  ) Looking at this for a second time, you could even have done pa = Point(x, y) pb = Point(rx, ry) Pset(x, y), pb Pset(rx, ry), pa Without any swapping. ^^ Just swap the variables... I'm so sleepy right now :zzz: (And I'm such a newb... *sigh*) Yours, - Neo
|
|
|
Logged
|
|
|
|
Dio
|
 |
« Reply #4 on: May 26, 2006, 07:25:15 PM » |
|
wow. just wow. i have got to be the absolute worst programmer on the face of the earth. why did i think i needed to swap the variables? jesus christ. thanks man. i am such a dumbass. honestly. ok. i'll need help later with some other shit i just know it. thanks.  edit: hmm, looks like sumo put the censors back on...should i bypass them? risky business...
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Neo
|
 |
« Reply #5 on: May 26, 2006, 07:36:18 PM » |
|
It's alright, no need to start swearing at yourself. I'm the one who's a newb here anyway :^_^:
Glad to have been of service,
- Neo.
|
|
|
Logged
|
|
|
|
Dio
|
 |
« Reply #6 on: May 28, 2006, 05:56:57 PM » |
|
success! i finished coding the encrypt/decrypt it was kinda hard. but now i need to know how to upload Bitmaps and save them. anybody know any good sites? thanks. screenres 1024,768,32,2,1 dim picx(100000000) dim picy(100000000) dim pic(100000000) dim i as double input "Pass "; p# randomize timer cls r =255':g = r:b =r for ww = 0 to 1000 step 1 'r = int(rnd*3)-1 'g = int(rnd*3)-1 'b = int(rnd*3)-1 r = r - 1 circle (1024/2,768/2),ww,rgb(r,g,b) circle (1024/2+1,768/2+1),ww,rgb(r,g,b) circle (1024/2+2,768/2+1),ww,rgb(r,g,b) next 1 sleep ymax = 767 xmax = 1023 randomize p# for y = 0 to ymax for x = 0 to xmax rx = int(rnd*xmax) ry = int(rnd*ymax) pa = point(x ,y ) pb = point(rx,ry) pset (x ,y ),pb pset (rx ,ry ),pa next next sleep randomize p# i = -1 for y = 0 to ymax for x = 0 to xmax i = i + 1 pix = int(rnd*xmax) pic(i) = pix i = i + 1 piy = int(rnd*ymax) pic(i) = piy next next i=((xmax+1)*(ymax+1))*2 do:loop until inkey$ <> "" for y = ymax to 0 step -1 for x = xmax to 0 step -1 i = i-1 ry = pic(i) i = i - 1 rx = pic(i) pa = point(x,y) pb = point(rx,ry) pset (x ,y ),pb pset (rx ,ry ),pa 'line (-1 ,-1 )-(100,100),0,b 'pset (100,y ),16777215 'pset (x ,100),16777215 next next sleep goto 1
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Zack
|
 |
« Reply #7 on: May 29, 2006, 02:10:39 PM » |
|
Register at fileanchor.com for free file hosting. Or do you need to know how to bload .bmp's into an FB program?
|
|
|
Logged
|
f only life let you press CTRL-Z. -------------------------------------- Freebasic is like QB, except it doesn't suck.
|
|
|
Dio
|
 |
« Reply #8 on: May 29, 2006, 05:12:45 PM » |
|
oh, sorry, i meant it in fb.
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Anonymous
Guest
|
 |
« Reply #9 on: May 29, 2006, 08:57:49 PM » |
|
do you mean upload a file to the internet using FB? if so, you could probably do that with winsock. and i think fb comes with an example called wshelper.bas (winsock helper), let me know if that's what you mean
|
|
|
Logged
|
|
|
|
Dio
|
 |
« Reply #10 on: May 30, 2006, 04:38:07 AM » |
|
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.
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Dio
|
 |
« Reply #11 on: May 30, 2006, 04:41:30 AM » |
|
and, if possible, have the computer detect the dimension (that means how big the picture is) automatically.
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Anonymous
Guest
|
 |
« Reply #12 on: May 30, 2006, 04:44:37 AM » |
|
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 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
|
|
|
Logged
|
|
|
|
Dio
|
 |
« Reply #13 on: May 30, 2006, 04:40:27 PM » |
|
cool thanks. 
|
|
|
Logged
|
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote] Here
|
|
|
Kylemc
|
 |
« Reply #14 on: May 31, 2006, 05:07:55 PM » |
|
Why not just encrypt the BMP or whatever file instead of messing around with the individual pixels?
|
|
|
Logged
|
|
|
|
|