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