Get Image Pixel

Blitz3D Forums/Blitz3D Programming/Get Image Pixel

KuRiX(Posted 2005) [#1]
Well, i am sure this can be done, but i cannot find how!

I Load an image (loadimage bla bla bla) and i want to get the color of the pixel x,y.

How?

Thanks Masters...


KuRiX(Posted 2005) [#2]
Ohhh, imagebuffer!

Sorry for asking!


KuRiX(Posted 2005) [#3]
Well, another problem:

I have a 256 Color Image (gray scale)

I want to read the image and store its values
in a matrix, where each value is a number between 0-255. Any Clues? Any Code?

Thaaanks.


SoggyP(Posted 2005) [#4]
Greetings Puppies,

I *think* blitz will automatically convert it to 16/32 bit depth. Look at the the ReadPixel and ReadPixelFast commands - search the forums if you need help understanding them because they've been explained to death elsewhere.

Peace,

Jes


KuRiX(Posted 2005) [#5]
Yep, i understand them. I read the image without problems, but i get values like -1671782.

I want values from 0 to 255 :(


SoggyP(Posted 2005) [#6]
Greetings Puppies,

In that case you don't understand them ;0) Try searching the forums, really. You'll find out all about the beauty of masking and bit shifting and I promise you'll get your answers.

Peace,

Jes


KuRiX(Posted 2005) [#7]
I know they are rgb values! I have coded bmp lot of times. Anyway i am searching the forums, hehe. Anyway, knowing that you *think* that Blitz converts it to 16-32 bits depth is a help.

Thanks.


KuRiX(Posted 2005) [#8]
Found IT!

argb=ReadPixelFast(x,y,ImageBuffer(image_name))
gotr=(ARGB Shr 16) And $ff
gotg=(ARGB Shr 8) And $ff
gotb=ARGB And $ff

GrayValue = (gotg+gotr+gotb) / 3


SoggyP(Posted 2005) [#9]
Greetings Puppies,

That's the one! See, the forums can be useful ;0)

Peace,

Jes