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