I am trying to decode a png, I have gotten to the poin where I have my raw png bytes. I have pretty much copied the example that was given.
I have created my bitmap
EwCreateBitmap( EW_PIXEL_FORMAT_NATIVE, frameSize, 0, 1 );
I then lock the area
lock = EwLockBitmap( bitmap, 0, lockArea, 0, 1 );
Obtain the pointer to the first pixel within the locked bitmap:
dest = (unsigned int*)lock->Pixel1;
After this is done, I begin to traverse the rows and colums of my png. I can printf the RGBA colors and see that they are correct as I am plugging them into the red, blue, green and alpha ints, I also the merge the values into a single 32 bit integer just as the example shows:
unsigned int red = ptr[0];
unsigned int green = ptr[1];
unsigned int blue = ptr[2];
unsigned int alpha = ptr[3];
*dest = red | green | blue | alpha;
My problem is that no matter what image I use, the image produced by my extern bitmap is always some kind of greyscale. I also noticed that blacks do not show.
I have tried numerous variations before merging the colors into a 32 bit int, these variations might produce a red tinted image or something like it, but the image never comes out exactly the way it should:
#ifdef EW_PREMULTIPLY_COLOR_CHANNELS
red = (( red * ( alpha + 1 )) >> 8 );
green = (( green * ( alpha + 1 )) >> 8 );
blue = (( blue * ( alpha + 1 )) >> 8 );
#endif
red <<= EW_COLOR_CHANNEL_BIT_OFFSET_RED;
green <<= EW_COLOR_CHANNEL_BIT_OFFSET_GREEN;
blue <<= EW_COLOR_CHANNEL_BIT_OFFSET_BLUE;
alpha <<= EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA;
Do you have any guidance?