X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99f73df9b4865aa3276319fb206127da9027fa63..4c7852186d48a5b8f406462c2c3fa020f0a052bb:/src/common/quantize.cpp?ds=sidebyside diff --git a/src/common/quantize.cpp b/src/common/quantize.cpp index b96e92e6de..07c63c52e2 100644 --- a/src/common/quantize.cpp +++ b/src/common/quantize.cpp @@ -42,7 +42,6 @@ #endif #ifndef WX_PRECOMP -#include "wx/wx.h" #endif #include "wx/image.h" @@ -1484,8 +1483,11 @@ void wxQuantize::DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, uns // TODO: somehow make use of the Windows system colours, rather than ignoring them for the // purposes of quantization. -bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours, - unsigned char** eightBitData, int flags) +bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, + wxPalette** pPalette, + int desiredNoColours, + unsigned char** eightBitData, + int flags) { int i; @@ -1560,6 +1562,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett else delete[] data8bit; +#if wxUSE_PALETTE // Make a wxWindows palette if (pPalette) { @@ -1605,6 +1608,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett delete[] g; delete[] b; } +#endif // wxUSE_PALETTE return TRUE; } @@ -1612,20 +1616,24 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett // This version sets a palette in the destination image so you don't // have to manage it yourself. -bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, int desiredNoColours, - unsigned char** eightBitData, int flags) +bool wxQuantize::Quantize(const wxImage& src, + wxImage& dest, + int desiredNoColours, + unsigned char** eightBitData, + int flags) { wxPalette* palette = NULL; - if (Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags)) + if ( !Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags) ) + return FALSE; + +#if wxUSE_PALETTE + if (palette) { - if (palette) - { - dest.SetPalette(* palette); - delete palette; - } - return TRUE; + dest.SetPalette(* palette); + delete palette; } - else - return FALSE; +#endif // wxUSE_PALETTE + + return TRUE; }