BlitzPlus GetColor() equivalent...

BlitzMax Forums/BlitzMax Beginners Area/BlitzPlus GetColor() equivalent...

Seb67(Posted 2009) [#1]
I'd like to pick the green (or red, blue) color of a x,y value of a pixmap. In BlitzPlus there's GetColor(x,y) and ColorGreen(), but that doesn't work in BlitzMax. I think I'll have to use ReadPixel(), but I obtain a 32bit value with rgb and alpha. How can I do to separate the green in a int variable ?

What's the difference between a TPixmap and a TImage ? Can I convert one to the other ? Why are two types to handle pictures ?

Thank you very much.


xlsior(Posted 2009) [#2]
- a pixmap is stored in 'normal' system memory.
- an image is stored in video memory, on the video card itself.

What this means:

- Pixmaps are slow to draw, since before drawing you'll need to upload them from normal RAM to video RAM
- since images are stored in video memory, out of reach of your program, you cannot make changes to an image
- If you need to change it, you'll have to use a pixmap, make the changes in normal memory, and re-upload it to the video memory either by converting it back to an image or by using drawpixmap (which does the same in the background)

As far as red/green/blue:

	pixcolor=ReadPixel(workpix,xx,yy)
	pixred=(pixcolor & $00FF0000) Shr 16
	pixgreen=(pixcolor & $0000FF00) Shr 8
	pixblue=(pixcolor & $000000FF)