Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

What are bitmap-related Windows version incompatibilities?
Started by Gabe-Forum@LEADTOOLS.com at 05-26-2006 9:51. Topic has 0 replies.

Print Search « Previous Thread Next Thread »
  05-26-2006, 9:51
Gabe-Forum@LEADTOOLS.com is not online. Last active: 10/1/2008 4:19:50 PM Gabe-Forum@LEADTOOLS.com



Top 25 Posts
Joined on 04-27-2005
Posts 236
What are bitmap-related Windows version incompatibilities?
Reply Quote

In the process of developing the AxTiff32.DLL, it became clear that CreateBitmapIndirect and other GDI function calls do not work the same way in Windows 95 as they do on Windows 3.1. No tests were performed on Windows NT. In short, someone introduced a bug into these functions by making the following assumption: bmWidthBytes = bmWidth * bmBitsPerPixel / 8;

Of course, this is only true if the bmWidth is a multiple of 32 and there is no padding to fill the buffer to an even doubleword boundary. In order to circumvent this problem, all Axtel DLL's and applications use the following sequence when creating a bitmap from a buffer:

/*
// There is a bug in MFC's 32-bit CreateBitmapIndirect.
// They seem to use bmWidth to calculate bmWidthBytes.
// Therefore, we must do the reverse.
// We will calculate BmWidth from bmWidthBytes.
// In other words, we will make our buffer appear to have no padding.
*/


dwLineLengthSave = m_sAxImage.dwLineLength;

#if defined
(WIN32)
m_sAxImage.dwLineLength = MulDiv(m_sAxImage.dwBuffWidth,8,m_sAxImage.wBitsPerPixel);

#endif

m_Bitmap.CreateBitmapIndirect((LPBITMAP)&m_sAxImage);
m_sAxImage.dwLineLength = dwLineLengthSave;

/*

// Free the buffer.
*/

GlobalUnlock(m_sAxImage.hBits);
GlobalFree(m_sAxImage.hBits);
m_sAxImage.hBits = 0;
m_sAxImage.pBits = NULL;

The conditionals may be removed when operating on a 32bit platform only.


   Report 
Post
LEAD Support Fo... » LEAD/Axtel Barc... » LEAD/Axtel FAQ » What are bitmap-related Windows version incompatibilities?

Powered by Community Server, by Telligent Systems