forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquantization.h
More file actions
69 lines (56 loc) · 1.75 KB
/
quantization.h
File metadata and controls
69 lines (56 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Aseprite Rener Library
// Copyright (c) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef RENDER_QUANTIZATION_H_INCLUDED
#define RENDER_QUANTIZATION_H_INCLUDED
#pragma once
#include "doc/dithering_method.h"
#include "doc/frame.h"
#include "doc/pixel_format.h"
#include "render/color_histogram.h"
#include <vector>
namespace doc {
class Image;
class Palette;
class RgbMap;
class Sprite;
}
namespace render {
using namespace doc;
class PaletteOptimizerDelegate {
public:
virtual ~PaletteOptimizerDelegate() { }
virtual void onPaletteOptimizerProgress(double progress) = 0;
virtual bool onPaletteOptimizerContinue() = 0;
};
class PaletteOptimizer {
public:
void feedWithImage(Image* image, bool withAlpha);
void feedWithRgbaColor(color_t color);
void calculate(Palette* palette, int maskIndex, PaletteOptimizerDelegate* delegate);
private:
ColorHistogram<5, 6, 5, 5> m_histogram;
};
// Creates a new palette suitable to quantize the given RGB sprite to Indexed color.
Palette* create_palette_from_sprite(
const Sprite* sprite,
frame_t fromFrame,
frame_t toFrame,
bool withAlpha,
Palette* newPalette, // Can be NULL to create a new palette
PaletteOptimizerDelegate* delegate);
// Changes the image pixel format. The dithering method is used only
// when you want to convert from RGB to Indexed.
Image* convert_pixel_format(
const Image* src,
Image* dst, // Can be NULL to create a new image
PixelFormat pixelFormat,
DitheringMethod ditheringMethod,
const RgbMap* rgbmap,
const Palette* palette,
bool is_background,
color_t new_mask_color);
} // namespace render
#endif