32 Bit ARGB Values?
BlitzMax Forums/BlitzMax Programming/32 Bit ARGB Values?
| ||
Hello, I am having trouble understanding the 32 bit ARGB Values for pixmaps. How do I set colors? I don't know how to read the value. Can you guys tell me how? |
| ||
Yeah, you need to bit shift and mask.pix = LoadPixmap("image.png") argb = readpixel(pix, 0, 0) blue = argb & 255 'this returns the bottom 8 bits green = (argb shr 8) & 255 'this shifts the bits right 8 places then returns the bottom 8 bits red = (argb shr 16) & 255 That might work, I'm not at the pc right now to check though. |
| ||
I find it easier to use a pointer.argb = readpixel(pix, 0, 0) argbP:byte ptr = Varptr argb blue = argbP[0] green = argbP[1] red = argbP[2] alpha = argbP[3] |
| ||
Ok. Do you know how I would use WritePixel() with the pointers? |
| ||
from the example: argbP just points to argb, you can write to argbP and pass it into Writepixel() argbP[0] = 255 .Writepixel(x,y,argb) |
| ||
Just to elaborate on what GW is saying (nice move with the pointers btw, I can't believe that never occurred to me):pix = LoadPixmap("image.png") argb = pix.Readpixel(0, 0) argbP:byte ptr = Varptr argb blue = argbP[0] green = argbP[1] red = argbP[2] alpha = argbP[3] argbP[0] = blue argbP[1] = green argbP[2] = red argbP[3] = alpha pix.WritePixel(x, y, argb) |
| ||
Ok, thanks for all of the help! |