Trying to learn getting info into and out of arrays.
Please look over my code , is that a good way to do it?
Rem Project: Arrays_lesson
Rem Created: Monday, August 09, 2010
Rem ***** Main Source File *****
sync on
sync rate 0
randomize timer()
Load Bitmap "layout.bmp", 1 `a 256 by 256 bitmap that uses only the 6 colors in the array
Set Current Bitmap 1
Lock Pixels
dim Pixel(256,256)
for x=1 to 256
for z=1 to 256
IF RGBR = (point(x,z)) = 255 Then Pixel (x,z)= 0 `red
IF RGBG = (point(x,z)) = 255 Then Pixel (x,z)= 1 `green
IF RGBB = (point(x,z)) = 255 Then Pixel (x,z)= 2 `blue
IF RGBR =0 and RGBG = 0 and RGBB = 0 Then Pixel(x,z)= 3 `black
If RGBR =255 and RGBG =255 and RGBB =255 Then Pixel(x,z)= 4 `white
If RGBR =127 and RGBG =127 and RGBB =127 Then Pixel(x,z)= 5 `grey
next z
next x
Unlock Pixels
Delete Bitmap
For the second part of my question; How do I get that info out of it?
I tried this;
sync on
sync rate 0
randomize timer()
Load Bitmap "layout.png", 1 `a 512 by 512 image that uses only the 6 colors in the array (you could have thousands of possible colors)
Set Current Bitmap 1
Lock Pixels
dim Pixel(512,512)
for x = 0 to 511
for z = 0 to 511
IF RGBR (point(x,z)) = 255 Then Pixel (x,z)= 0 `red
IF RGBG (point(x,z)) = 255 Then Pixel (x,z)= 1 `green
IF RGBB (point(x,z)) = 255 Then Pixel (x,z)= 2 `blue
IF RGBR (point(x,z))=0 and RGBG(point(x,z)) = 0 and RGBB(point(x,z)) = 0 Then Pixel(x,z)= 3 `black
If RGBR (point(x,z))=255 and RGBG(point(x,z)) =255 and RGBB(point(x,z)) =255 Then Pixel(x,z)= 4 `white
If RGBR (point(x,z))=127 and RGBG(point(x,z)) =127 and RGBB(point(x,z)) =127 Then Pixel(x,z)= 5 `grey
next z
next x
Unlock Pixels
Delete Bitmap
For x = 0 to 511
For z = 0 to 511
If Pixel (x,z) = 0
Inc ojb
Make object box obj, 1
Position Object obj, x,0,z
ENDIF
NEXT Z
NEXT X
Thanks for any comments.
Mike
some cool stuff someone else said here