#include "wx/filefn.h"
#include "wx/wfstream.h"
#include "wx/quantize.h"
+#include "wx/scopeguard.h"
#include "wx/anidecod.h"
// For memcpy
case wxIMAGE_RESOLUTION_INCHES:
// convert resolution in inches to resolution in centimeters
- hres = (wxUint32)(100*mm2inches*hres);
- vres = (wxUint32)(100*mm2inches*vres);
+ hres = (wxUint32)(10*mm2inches*hres);
+ vres = (wxUint32)(10*mm2inches*vres);
// fall through to convert it to resolution in meters
case wxIMAGE_RESOLUTION_CM:
}
-typedef struct
+struct BMPPalette
{
+ static void Free(BMPPalette* pal) { delete [] pal; }
+
unsigned char r, g, b;
-} _cmap;
+};
bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
int bpp, int ncolors, int comp,
wxUint16 aWord;
// allocate space for palette if needed:
- _cmap *cmap;
+ BMPPalette *cmap;
if ( bpp < 16 )
{
- cmap = new _cmap[ncolors];
+ cmap = new BMPPalette[ncolors];
if ( !cmap )
{
if (verbose)
return false;
}
}
- else
+ else // no palette
+ {
cmap = NULL;
+ }
+
+ wxON_BLOCK_EXIT1(&BMPPalette::Free, cmap);
// destroy existing here instead of:
image->Destroy();
{
if ( verbose )
wxLogError( _("BMP: Couldn't allocate memory.") );
- delete[] cmap;
return false;
}
{
if ( verbose )
wxLogError(_("BMP: Couldn't allocate memory."));
- delete[] cmap;
return false;
}
}
}
}
- delete[] cmap;
-
image->SetMask(false);
const wxStreamError err = stream.GetLastError();