]>
Commit | Line | Data |
---|---|---|
3f4fc796 | 1 | ///////////////////////////////////////////////////////////////////////////// |
3bc2d7ae | 2 | // Name: wx/quantize.h |
3f4fc796 JS |
3 | // Purpose: wxQuantizer class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 22/6/2000 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
20ceebaa MW |
12 | #ifndef _WX_QUANTIZE_H_ |
13 | #define _WX_QUANTIZE_H_ | |
14 | ||
3bc2d7ae WS |
15 | #include "wx/object.h" |
16 | ||
3f4fc796 JS |
17 | /* |
18 | * From jquant2.c | |
19 | * | |
20 | * Copyright (C) 1991-1996, Thomas G. Lane. | |
21 | * This file is part of the Independent JPEG Group's software. | |
22 | * For conditions of distribution and use, see the accompanying README file. | |
23 | */ | |
24 | ||
3f4fc796 | 25 | class WXDLLEXPORT wxImage; |
3bc2d7ae | 26 | class WXDLLEXPORT wxPalette; |
3f4fc796 JS |
27 | |
28 | /* | |
29 | * wxQuantize | |
30 | * Based on the JPEG quantization code. Reduces the number of colours in a wxImage. | |
31 | */ | |
32 | ||
33 | #define wxQUANTIZE_INCLUDE_WINDOWS_COLOURS 0x01 | |
34 | #define wxQUANTIZE_RETURN_8BIT_DATA 0x02 | |
35 | #define wxQUANTIZE_FILL_DESTINATION_IMAGE 0x04 | |
36 | ||
37 | class WXDLLEXPORT wxQuantize: public wxObject | |
38 | { | |
39 | public: | |
40 | DECLARE_DYNAMIC_CLASS(wxQuantize) | |
41 | ||
42 | //// Constructor | |
43 | ||
d84afea9 GD |
44 | wxQuantize() {} |
45 | ~wxQuantize() {} | |
3f4fc796 JS |
46 | |
47 | //// Operations | |
48 | ||
49 | // Reduce the colours in the source image and put the result into the | |
50 | // destination image. Both images may be the same, to overwrite the source image. | |
51 | // Specify an optional palette pointer to receive the resulting palette. | |
52 | // This palette may be passed to ConvertImageToBitmap, for example. | |
53 | // If you pass a palette pointer, you must free the palette yourself. | |
54 | ||
85d03040 | 55 | static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours = 236, |
3f4fc796 JS |
56 | unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); |
57 | ||
2f382cc6 JS |
58 | // This version sets a palette in the destination image so you don't |
59 | // have to manage it yourself. | |
60 | ||
61 | static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236, | |
62 | unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); | |
63 | ||
3f4fc796 JS |
64 | //// Helpers |
65 | ||
66 | // Converts input bitmap(s) into 8bit representation with custom palette | |
7e548f6b | 67 | |
3f4fc796 JS |
68 | // in_rows and out_rows are arrays [0..h-1] of pointer to rows |
69 | // (in_rows contains w * 3 bytes per row, out_rows w bytes per row) | |
70 | // fills out_rows with indexes into palette (which is also stored into palette variable) | |
71 | static void DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, unsigned char **out_rows, unsigned char *palette, int desiredNoColours); | |
72 | ||
73 | }; | |
74 | ||
75 | #endif | |
76 | // _WX_QUANTIZE_H_ |