2014-12-28 22:06:11 +08:00
|
|
|
// Aseprite Rener Library
|
2015-05-21 21:17:59 +08:00
|
|
|
// Copyright (c) 2001-2015 David Capello
|
2014-12-28 22:06:11 +08:00
|
|
|
//
|
|
|
|
// 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"
|
2014-12-29 07:39:11 +08:00
|
|
|
#include "doc/frame.h"
|
2014-12-28 22:06:11 +08:00
|
|
|
#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;
|
|
|
|
|
2015-07-02 22:18:43 +08:00
|
|
|
class PaletteOptimizer {
|
|
|
|
public:
|
|
|
|
void feedWithImage(Image* image, bool withAlpha);
|
2015-07-23 03:40:44 +08:00
|
|
|
void feedWithRgbaColor(color_t color);
|
|
|
|
void calculate(Palette* palette, int maskIndex);
|
2014-12-28 22:06:11 +08:00
|
|
|
|
|
|
|
private:
|
2015-07-02 22:18:43 +08:00
|
|
|
ColorHistogram<5, 6, 5, 5> m_histogram;
|
2014-12-28 22:06:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Creates a new palette suitable to quantize the given RGB sprite to Indexed color.
|
|
|
|
Palette* create_palette_from_rgb(
|
|
|
|
const Sprite* sprite,
|
2015-05-21 21:17:59 +08:00
|
|
|
frame_t fromFrame,
|
|
|
|
frame_t toFrame,
|
2015-07-02 22:18:43 +08:00
|
|
|
bool withAlpha,
|
|
|
|
Palette* newPalette); // Can be NULL to create a new palette
|
2014-12-28 22:06:11 +08:00
|
|
|
|
|
|
|
// 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,
|
2015-07-14 20:44:31 +08:00
|
|
|
bool is_background,
|
|
|
|
color_t new_mask_color);
|
2014-12-28 22:06:11 +08:00
|
|
|
|
|
|
|
} // namespace render
|
|
|
|
|
|
|
|
#endif
|