SetPixel and Color
Hello,
I have loaded a bitmap resource using:
..
..
..
po_StartBitmap[6] =(BYTE*)
LockResource(LoadResource(NULL,FindResource(NULL,MAKEINTRESOURCE(IDB_WHITEPAWN),RT_BITMAP)));
I probably should have done this using GetDIBits() but i could not get
it to work just now, so i tried this instead.
It does what i want, getting a pointer to the bitmapdata, may try
GetDIBits() later.
I want to draw the bitmap in OnDraw() using SetPixel().
Like so:
void CPGNFENEditorView::Draw_WhitePawn(int n_X, int n_Y, CDC *po_dc)
{
BYTE* po_Bitmap;
po_Bitmap = po_StartBitmap[6];
int nWidth =55;
int nHeight =64;
int nX,nY;
po_Bitmap+=40; // start pixeldata
for(nY = 0; nY < nHeight; nY ++)
{
for(nX = 0; nX < nWidth; nX++)
{
if( *(po_Bitmap ) != 0xff || *(po_Bitmap + 1) != 0xff ||
*(po_Bitmap + 2) != 0xff)
po_dc->SetPixel (n_X+nX,n_Y+nY,RGB(*(po_Bitmap),*(po_Bitmap
+1),*(po_Bitmap+2)));
po_Bitmap+=3;
}
po_Bitmap+=3; // skip trailing zeros for multiples of four.
}
}
I have a bitmap with a black king (chesspiece) which is black, this
bitmap is drawn perfectly using the SetPixel() code. (Its black and
the shape is what it should be)
Then i have a bitmap with a white king which is actually yellow in
color.
The above code displayes the bitmap perfectly, BUT its not yellow but
blue!
How can the bitmap be displayed perfectly but be of a different color
than it originally is?