]> git.saurik.com Git - wxWidgets.git/commitdiff
Added version of Quantize that manages the palette itself
authorJulian Smart <julian@anthemion.co.uk>
Sat, 29 Jul 2000 13:41:56 +0000 (13:41 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 29 Jul 2000 13:41:56 +0000 (13:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/quantize.h
src/common/quantize.cpp

index dd50cf7102053a536749a780afbd7b366f32edab..592718e431377b126dd53262c1743d32241ed3ae 100644 (file)
@@ -55,6 +55,12 @@ DECLARE_DYNAMIC_CLASS(wxQuantize)
     static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette = NULL, int desiredNoColours = 236,
         unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA);
 
+    // This version sets a palette in the destination image so you don't
+    // have to manage it yourself.
+
+    static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236,
+        unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA);
+
 //// Helpers
 
     // Converts input bitmap(s) into 8bit representation with custom palette
index 5f579ba9efd8dc71221186f5fe20606bbd6c14b8..331a620edd6c3b0debb9dc8381557ad344fee3cb 100644 (file)
@@ -1562,3 +1562,23 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalett
     return TRUE;
 }
 
+// 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)
+{
+    wxPalette* palette = NULL;
+    if (Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags))
+    {
+        if (palette)
+        {
+            dest.SetPalette(* palette);
+            delete palette;
+        }
+        return TRUE;
+    }
+    else
+        return FALSE;
+}
+