wxBitmap wxImage::ConvertToBitmap() const
{
+ if ( !Ok() )
+ return wxNullBitmap;
+
// sizeLimit is the MS upper limit for the DIB size
int sizeLimit = 1024*768*3;
// calc the number of bytes per scanline and padding
int bytePerLine = width*3;
int sizeDWORD = sizeof( DWORD );
- div_t lineBoundary = div( bytePerLine, sizeDWORD );
+ int lineBoundary = bytePerLine % sizeDWORD;
int padding = 0;
- if( lineBoundary.rem > 0 )
+ if( lineBoundary > 0 )
{
- padding = sizeDWORD - lineBoundary.rem;
+ padding = sizeDWORD - lineBoundary;
bytePerLine += padding;
}
// calc the number of DIBs and heights of DIBs
height = bmpHeight;
else
{
- div_t result = div( bmpHeight, height );
- numDIB = result.quot;
- hRemain = result.rem;
+ numDIB = bmpHeight / height;
+ hRemain = bmpHeight % height;
if( hRemain >0 ) numDIB++;
}
// calc the number of bytes per scanline and padding in the DIB
int bytePerLine = width*3;
int sizeDWORD = sizeof( DWORD );
- div_t lineBoundary = div( bytePerLine, sizeDWORD );
+ int lineBoundary = bytePerLine % sizeDWORD;
int padding = 0;
- if( lineBoundary.rem > 0 )
+ if( lineBoundary > 0 )
{
- padding = sizeDWORD - lineBoundary.rem;
+ padding = sizeDWORD - lineBoundary;
bytePerLine += padding;
}