Author Topic: GetBits code messes up?  (Read 1305 times)

glina126

  • Guest
GetBits code messes up?
« on: October 06, 2012, 07:48:40 pm »
ok so I have this simple code

Code: [Select]

for(int x = 0; x < 320; x++)
{
for(int y = 0; y < 480; y++)
{
BitmapSetPixel(bitmap,x,y,225,225,225,111);
}

}

BitmapUpdate(bitmap);

unsigned char *MyBits = BitmapGetBits(bitmap);

int blue = MyBits[(10*(320+10))*4 + 1];

char blue_char[20];

sprintf(blue_char,"%i",blue);
printf(blue_char);


it should print out 225 but instead i get 98?

also if I load an image to the bitmap surface, all the bits are set to 255 while I have a pure white image. why is this? I tried running this with all different images of different colors and all of them have all bits set to 255.

Also a note, MyBits[(10*(320+10))*4 ]; is = to ALPHA while it should be Blue. Is this function corrupt?
« Last Edit: October 06, 2012, 07:54:09 pm by glina126 »

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: GetBits code messes up?
« Reply #1 on: October 12, 2012, 08:42:20 am »
98 is the correct value.  Yes, your RGB values are all 255, but your alpha is 111.  If the alpha value were 255, then your char would also be 255...
Tim Sommers
DragonFireSDK Team

glina126

  • Guest
Re: GetBits code messes up?
« Reply #2 on: October 15, 2012, 05:40:18 am »
from what I remember the same thing would happen with alpha being set to 255. I will check it and get back soon.