CBitmap alignment issue
Hi folks,
I am trying to use CBitmap and HBITMAP to display 24bpp images in my Windows
Mobile 5.0 application.
Everything works fine as long as my image is aligned on 4 bytes. Now not all
images are like that.
I tried the following:
******************************************************************
// get a buffer with 4-bytes aligned pixels
unsigned char* pBits = extractPixelDataAlignedBytes( );
// create a CBitmap
CBitmap* pBmp = new CBitmap();
pBmp->CreateBitmap(iWidth, iHeight, nPlanes, nBitcount, (const void*)
pBits) )
// Display image in CView::OnDraw()
{
....
HBITMAP hBmp = (HBITMAP)*pBmp;
if( hBmp )
{
CRect rcClient;
GetClientRect(&rcClient);
dcMem.CreateCompatibleDC(NULL);
dcMem.SelectObject(hBmp);
pDC->StretchBlt(rcClient.left, rcClient.top,
rcClient.right, rcClient.bottom,
&dcMem,
0,
0,
BmpWidth,
BmpHeight,
SRCCOPY);
}
}
*********************************************************************
The image is not displayed properly when I need to add 2 or 3 bytes at the
end of each line to be aligned on 4-bytes. That works when I need to add 1
byte to be aligned on 4-bytes...
Did I miss something? Is what I want to do possible with CBitmap object or
do I need to use a DIB object? (if not CBitmap are useless)
Thanks in advance
--
ST
---------------------------
stopin@nospam.nospam