PDA

View Full Version : 16 bit bitmap help


OdeeanRDeathshead
07-02-2006, 02:07 PM
I have been trying to read in a 16 bit bitmap but I am having a hard time getting the clours correct.

The code that determines position and reading the data are good. I think this because I do get a picture that looks correct, but the colours are wrong.

here is the code to put the colours in....

ushort q=0;
memcpy(&q,((ushort*)(readBuffer+(Lindex*ReadBytesPerPixcel ) )),ReadBytesPerPixcel);

ushort rr=(( (q )& 0x001f )<<3);
ushort gg=(( (q>>5 )& 0x003f )<<2);
ushort bb=(( (q>>11)& 0x001f )<<3);

ushort qQ= ( (rr>>3)<<11) | ((gg>>2)<<5) | ((bb>>3));

*((ushort*)(tempBuffer+(Tindex*bytesPerPixcel)))=q Q;



the readbytesperpixcel and bytesperpixcel are both 2 (ie 16 bits) int this instance. The bitmap is also a 16 bit bitmap that opens in pie properly.

The device is a 565 display.

OdeeanRDeathshead
07-02-2006, 02:13 PM
Don't wory I just fixed it. The software I was generating the bitmap with was making rgb pixcels instead of bgr(normal bitmap order). And it was generating 555 instead of 565.


fixed

ushort q=0;
memcpy(&q,((ushort*)(readBuffer+(Lindex*ReadBytesPerPixcel ) )),ReadBytesPerPixcel);

//555 in
ushort bb=(( (q )& 0x001f )<<3);
ushort gg=(( (q>>5 )& 0x001f )<<3);
ushort rr=(( (q>>10)& 0x001f )<<3);

ushort qQ= ( (rr>>3)<<11) | ((gg>>2)<<5) | ((bb>>3));

*((ushort*)(tempBuffer+(Tindex*bytesPerPixcel)))=q Q;