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