X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b134516c10ba5e1d86e67765cdac5f64aa4ff576..60b6c062f847a742fbc3c4ba4023bb8a0235da6d:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index bb00088242..f769be03a4 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -150,7 +150,7 @@ void wxImage::Destroy() UnRef(); } -wxImage wxImage::Scale( int width, int height ) +wxImage wxImage::Scale( int width, int height ) const { wxImage image; @@ -582,6 +582,9 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE wxBitmap wxImage::ConvertToBitmap() const { + if ( !Ok() ) + return wxNullBitmap; + // sizeLimit is the MS upper limit for the DIB size int sizeLimit = 1024*768*3; @@ -592,11 +595,11 @@ wxBitmap wxImage::ConvertToBitmap() const // 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 @@ -607,9 +610,8 @@ wxBitmap wxImage::ConvertToBitmap() const 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++; } @@ -805,11 +807,11 @@ wxImage::wxImage( const wxBitmap &bitmap ) // 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; }