mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Move doc::DitheringMethod -> render::DitheringAlgorithm
This commit is contained in:
parent
e4a4f44127
commit
23272895c4
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -31,7 +31,8 @@ namespace cmd {
|
|||||||
using namespace doc;
|
using namespace doc;
|
||||||
|
|
||||||
SetPixelFormat::SetPixelFormat(Sprite* sprite,
|
SetPixelFormat::SetPixelFormat(Sprite* sprite,
|
||||||
PixelFormat newFormat, DitheringMethod dithering)
|
const PixelFormat newFormat,
|
||||||
|
const render::DitheringAlgorithm dithering)
|
||||||
: WithSprite(sprite)
|
: WithSprite(sprite)
|
||||||
, m_oldFormat(sprite->pixelFormat())
|
, m_oldFormat(sprite->pixelFormat())
|
||||||
, m_newFormat(newFormat)
|
, m_newFormat(newFormat)
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#define APP_CMD_SET_PIXEL_FORMAT_H_INCLUDED
|
#define APP_CMD_SET_PIXEL_FORMAT_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/cmd_sequence.h"
|
|
||||||
#include "app/cmd/with_sprite.h"
|
#include "app/cmd/with_sprite.h"
|
||||||
|
#include "app/cmd_sequence.h"
|
||||||
#include "doc/pixel_format.h"
|
#include "doc/pixel_format.h"
|
||||||
#include "doc/dithering_method.h"
|
#include "render/dithering_algorithm.h"
|
||||||
|
|
||||||
namespace doc {
|
namespace doc {
|
||||||
class Sprite;
|
class Sprite;
|
||||||
@ -19,14 +19,13 @@ namespace doc {
|
|||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace cmd {
|
namespace cmd {
|
||||||
using namespace doc;
|
|
||||||
|
|
||||||
class SetPixelFormat : public Cmd
|
class SetPixelFormat : public Cmd
|
||||||
, public WithSprite {
|
, public WithSprite {
|
||||||
public:
|
public:
|
||||||
SetPixelFormat(Sprite* sprite,
|
SetPixelFormat(doc::Sprite* sprite,
|
||||||
PixelFormat newFormat,
|
const doc::PixelFormat newFormat,
|
||||||
DitheringMethod dithering);
|
const render::DitheringAlgorithm dithering);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onExecute() override;
|
void onExecute() override;
|
||||||
@ -39,9 +38,9 @@ namespace cmd {
|
|||||||
private:
|
private:
|
||||||
void setFormat(PixelFormat format);
|
void setFormat(PixelFormat format);
|
||||||
|
|
||||||
PixelFormat m_oldFormat;
|
doc::PixelFormat m_oldFormat;
|
||||||
PixelFormat m_newFormat;
|
doc::PixelFormat m_newFormat;
|
||||||
DitheringMethod m_dithering;
|
render::DitheringAlgorithm m_dithering;
|
||||||
CmdSequence m_seq;
|
CmdSequence m_seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,15 +16,16 @@
|
|||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
#include "app/transaction.h"
|
#include "app/transaction.h"
|
||||||
#include "doc/dithering_method.h"
|
|
||||||
#include "doc/image.h"
|
#include "doc/image.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
|
#include "render/dithering_algorithm.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class ChangePixelFormatCommand : public Command {
|
class ChangePixelFormatCommand : public Command {
|
||||||
PixelFormat m_format;
|
doc::PixelFormat m_format;
|
||||||
DitheringMethod m_dithering;
|
render::DitheringAlgorithm m_dithering;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChangePixelFormatCommand();
|
ChangePixelFormatCommand();
|
||||||
Command* clone() const override { return new ChangePixelFormatCommand(*this); }
|
Command* clone() const override { return new ChangePixelFormatCommand(*this); }
|
||||||
@ -42,7 +43,7 @@ ChangePixelFormatCommand::ChangePixelFormatCommand()
|
|||||||
CmdUIOnlyFlag)
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
m_format = IMAGE_RGB;
|
m_format = IMAGE_RGB;
|
||||||
m_dithering = DitheringMethod::NONE;
|
m_dithering = render::DitheringAlgorithm::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangePixelFormatCommand::onLoadParams(const Params& params)
|
void ChangePixelFormatCommand::onLoadParams(const Params& params)
|
||||||
@ -54,9 +55,9 @@ void ChangePixelFormatCommand::onLoadParams(const Params& params)
|
|||||||
|
|
||||||
std::string dithering = params.get("dithering");
|
std::string dithering = params.get("dithering");
|
||||||
if (dithering == "ordered")
|
if (dithering == "ordered")
|
||||||
m_dithering = DitheringMethod::ORDERED;
|
m_dithering = render::DitheringAlgorithm::Ordered;
|
||||||
else
|
else
|
||||||
m_dithering = DitheringMethod::NONE;
|
m_dithering = render::DitheringAlgorithm::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChangePixelFormatCommand::onEnabled(Context* context)
|
bool ChangePixelFormatCommand::onEnabled(Context* context)
|
||||||
@ -67,7 +68,7 @@ bool ChangePixelFormatCommand::onEnabled(Context* context)
|
|||||||
if (sprite != NULL &&
|
if (sprite != NULL &&
|
||||||
sprite->pixelFormat() == IMAGE_INDEXED &&
|
sprite->pixelFormat() == IMAGE_INDEXED &&
|
||||||
m_format == IMAGE_INDEXED &&
|
m_format == IMAGE_INDEXED &&
|
||||||
m_dithering == DitheringMethod::ORDERED)
|
m_dithering == render::DitheringAlgorithm::Ordered)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
@ -81,7 +82,7 @@ bool ChangePixelFormatCommand::onChecked(Context* context)
|
|||||||
if (sprite != NULL &&
|
if (sprite != NULL &&
|
||||||
sprite->pixelFormat() == IMAGE_INDEXED &&
|
sprite->pixelFormat() == IMAGE_INDEXED &&
|
||||||
m_format == IMAGE_INDEXED &&
|
m_format == IMAGE_INDEXED &&
|
||||||
m_dithering == DitheringMethod::ORDERED)
|
m_dithering == render::DitheringAlgorithm::Ordered)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -270,7 +270,7 @@ void NewLayerCommand::onExecute(Context* context)
|
|||||||
pasteImage.get(),
|
pasteImage.get(),
|
||||||
nullptr,
|
nullptr,
|
||||||
sprite->pixelFormat(),
|
sprite->pixelFormat(),
|
||||||
DitheringMethod::NONE,
|
render::DitheringAlgorithm::None,
|
||||||
sprite->rgbMap(dstFrame),
|
sprite->rgbMap(dstFrame),
|
||||||
pasteSpr->palette(fr),
|
pasteSpr->palette(fr),
|
||||||
(pasteSpr->backgroundLayer() ? true: false),
|
(pasteSpr->backgroundLayer() ? true: false),
|
||||||
|
@ -184,7 +184,8 @@ void PasteTextCommand::onExecute(Context* ctx)
|
|||||||
image.reset(
|
image.reset(
|
||||||
render::convert_pixel_format(
|
render::convert_pixel_format(
|
||||||
image.get(), NULL, sprite->pixelFormat(),
|
image.get(), NULL, sprite->pixelFormat(),
|
||||||
DitheringMethod::NONE, rgbmap, sprite->palette(editor->frame()),
|
render::DitheringAlgorithm::None, rgbmap,
|
||||||
|
sprite->palette(editor->frame()),
|
||||||
false, 0));
|
false, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,9 @@ void DocumentApi::trimSprite(Sprite* sprite)
|
|||||||
cropSprite(sprite, bounds);
|
cropSprite(sprite, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, DitheringMethod dithering)
|
void DocumentApi::setPixelFormat(Sprite* sprite,
|
||||||
|
const PixelFormat newFormat,
|
||||||
|
const render::DitheringAlgorithm dithering)
|
||||||
{
|
{
|
||||||
if (sprite->pixelFormat() == newFormat)
|
if (sprite->pixelFormat() == newFormat)
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
#include "doc/algorithm/flip_type.h"
|
#include "doc/algorithm/flip_type.h"
|
||||||
#include "doc/color.h"
|
#include "doc/color.h"
|
||||||
#include "doc/dithering_method.h"
|
|
||||||
#include "doc/frame.h"
|
#include "doc/frame.h"
|
||||||
#include "doc/image_ref.h"
|
#include "doc/image_ref.h"
|
||||||
#include "doc/pixel_format.h"
|
#include "doc/pixel_format.h"
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
|
#include "render/dithering_algorithm.h"
|
||||||
|
|
||||||
namespace doc {
|
namespace doc {
|
||||||
class Cel;
|
class Cel;
|
||||||
@ -46,7 +46,9 @@ namespace app {
|
|||||||
void setSpriteTransparentColor(Sprite* sprite, color_t maskColor);
|
void setSpriteTransparentColor(Sprite* sprite, color_t maskColor);
|
||||||
void cropSprite(Sprite* sprite, const gfx::Rect& bounds);
|
void cropSprite(Sprite* sprite, const gfx::Rect& bounds);
|
||||||
void trimSprite(Sprite* sprite);
|
void trimSprite(Sprite* sprite);
|
||||||
void setPixelFormat(Sprite* sprite, PixelFormat newFormat, DitheringMethod dithering);
|
void setPixelFormat(Sprite* sprite,
|
||||||
|
const PixelFormat newFormat,
|
||||||
|
const render::DitheringAlgorithm dithering);
|
||||||
|
|
||||||
// Frames API
|
// Frames API
|
||||||
void addFrame(Sprite* sprite, frame_t newFrame);
|
void addFrame(Sprite* sprite, frame_t newFrame);
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "doc/algorithm/shrink_bounds.h"
|
#include "doc/algorithm/shrink_bounds.h"
|
||||||
#include "doc/cel.h"
|
#include "doc/cel.h"
|
||||||
#include "doc/dithering_method.h"
|
|
||||||
#include "doc/frame_tag.h"
|
#include "doc/frame_tag.h"
|
||||||
#include "doc/image.h"
|
#include "doc/image.h"
|
||||||
#include "doc/layer.h"
|
#include "doc/layer.h"
|
||||||
@ -38,6 +37,7 @@
|
|||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
#include "gfx/packing_rects.h"
|
#include "gfx/packing_rects.h"
|
||||||
#include "gfx/size.h"
|
#include "gfx/size.h"
|
||||||
|
#include "render/dithering_algorithm.h"
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -707,7 +707,8 @@ void DocumentExporter::renderTexture(const Samples& samples, Image* textureImage
|
|||||||
cmd::SetPixelFormat(
|
cmd::SetPixelFormat(
|
||||||
sample.sprite(),
|
sample.sprite(),
|
||||||
textureImage->pixelFormat(),
|
textureImage->pixelFormat(),
|
||||||
DitheringMethod::NONE).execute(UIContext::instance());
|
render::DitheringAlgorithm::None)
|
||||||
|
.execute(UIContext::instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSample(sample, textureImage,
|
renderSample(sample, textureImage,
|
||||||
|
@ -695,7 +695,8 @@ private:
|
|||||||
Image* oldImage = cel->image();
|
Image* oldImage = cel->image();
|
||||||
ImageRef newImage(
|
ImageRef newImage(
|
||||||
render::convert_pixel_format
|
render::convert_pixel_format
|
||||||
(oldImage, NULL, IMAGE_RGB, DitheringMethod::NONE,
|
(oldImage, NULL, IMAGE_RGB,
|
||||||
|
render::DitheringAlgorithm::None,
|
||||||
nullptr,
|
nullptr,
|
||||||
m_sprite->palette(cel->frame()),
|
m_sprite->palette(cel->frame()),
|
||||||
m_opaque,
|
m_opaque,
|
||||||
@ -706,7 +707,8 @@ private:
|
|||||||
|
|
||||||
m_currentImage.reset(
|
m_currentImage.reset(
|
||||||
render::convert_pixel_format
|
render::convert_pixel_format
|
||||||
(m_currentImage.get(), NULL, IMAGE_RGB, DitheringMethod::NONE,
|
(m_currentImage.get(), NULL, IMAGE_RGB,
|
||||||
|
render::DitheringAlgorithm::None,
|
||||||
nullptr,
|
nullptr,
|
||||||
m_sprite->palette(m_frameNum),
|
m_sprite->palette(m_frameNum),
|
||||||
m_opaque,
|
m_opaque,
|
||||||
@ -714,7 +716,8 @@ private:
|
|||||||
|
|
||||||
m_previousImage.reset(
|
m_previousImage.reset(
|
||||||
render::convert_pixel_format
|
render::convert_pixel_format
|
||||||
(m_previousImage.get(), NULL, IMAGE_RGB, DitheringMethod::NONE,
|
(m_previousImage.get(), NULL, IMAGE_RGB,
|
||||||
|
render::DitheringAlgorithm::None,
|
||||||
nullptr,
|
nullptr,
|
||||||
m_sprite->palette(MAX(0, m_frameNum-1)),
|
m_sprite->palette(MAX(0, m_frameNum-1)),
|
||||||
m_opaque,
|
m_opaque,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/file/format_options.h"
|
#include "app/file/format_options.h"
|
||||||
#include "doc/dithering_method.h"
|
#include "render/dithering_algorithm.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
|
@ -332,7 +332,8 @@ void paste()
|
|||||||
src_image.reset(
|
src_image.reset(
|
||||||
render::convert_pixel_format(
|
render::convert_pixel_format(
|
||||||
clipboard_image.get(), NULL, dstSpr->pixelFormat(),
|
clipboard_image.get(), NULL, dstSpr->pixelFormat(),
|
||||||
DitheringMethod::NONE, dst_rgbmap, clipboard_palette.get(),
|
render::DitheringAlgorithm::None,
|
||||||
|
dst_rgbmap, clipboard_palette.get(),
|
||||||
false,
|
false,
|
||||||
0));
|
0));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -52,7 +52,7 @@ Cel* create_cel_copy(const Cel* srcCel,
|
|||||||
celImage,
|
celImage,
|
||||||
tmpImage.get(),
|
tmpImage.get(),
|
||||||
IMAGE_RGB,
|
IMAGE_RGB,
|
||||||
DitheringMethod::NONE,
|
render::DitheringAlgorithm::None,
|
||||||
srcCel->sprite()->rgbMap(srcCel->frame()),
|
srcCel->sprite()->rgbMap(srcCel->frame()),
|
||||||
srcCel->sprite()->palette(srcCel->frame()),
|
srcCel->sprite()->palette(srcCel->frame()),
|
||||||
srcCel->layer()->isBackground(),
|
srcCel->layer()->isBackground(),
|
||||||
@ -62,7 +62,7 @@ Cel* create_cel_copy(const Cel* srcCel,
|
|||||||
tmpImage.get(),
|
tmpImage.get(),
|
||||||
dstCel->image(),
|
dstCel->image(),
|
||||||
IMAGE_INDEXED,
|
IMAGE_INDEXED,
|
||||||
DitheringMethod::NONE,
|
render::DitheringAlgorithm::None,
|
||||||
dstSprite->rgbMap(dstFrame),
|
dstSprite->rgbMap(dstFrame),
|
||||||
dstSprite->palette(dstFrame),
|
dstSprite->palette(dstFrame),
|
||||||
srcCel->layer()->isBackground(),
|
srcCel->layer()->isBackground(),
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
// Aseprite Document Library
|
|
||||||
// Copyright (c) 2001-2014 David Capello
|
|
||||||
//
|
|
||||||
// This file is released under the terms of the MIT license.
|
|
||||||
// Read LICENSE.txt for more information.
|
|
||||||
|
|
||||||
#ifndef DOC_DITHERING_METHOD_H_INCLUDED
|
|
||||||
#define DOC_DITHERING_METHOD_H_INCLUDED
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace doc {
|
|
||||||
|
|
||||||
// Dithering methods
|
|
||||||
enum class DitheringMethod {
|
|
||||||
NONE,
|
|
||||||
ORDERED,
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace doc
|
|
||||||
|
|
||||||
#endif
|
|
22
src/render/dithering_algorithm.h
Normal file
22
src/render/dithering_algorithm.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Aseprite Render Library
|
||||||
|
// Copyright (c) 2001-2017 David Capello
|
||||||
|
//
|
||||||
|
// This file is released under the terms of the MIT license.
|
||||||
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
#ifndef RENDER_DITHERING_METHOD_H_INCLUDED
|
||||||
|
#define RENDER_DITHERING_METHOD_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace render {
|
||||||
|
|
||||||
|
// Dithering algorithms
|
||||||
|
enum class DitheringAlgorithm {
|
||||||
|
None,
|
||||||
|
OldOrdered,
|
||||||
|
Ordered,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace render
|
||||||
|
|
||||||
|
#endif
|
@ -36,9 +36,9 @@ using namespace gfx;
|
|||||||
|
|
||||||
Palette* create_palette_from_sprite(
|
Palette* create_palette_from_sprite(
|
||||||
const Sprite* sprite,
|
const Sprite* sprite,
|
||||||
frame_t fromFrame,
|
const frame_t fromFrame,
|
||||||
frame_t toFrame,
|
const frame_t toFrame,
|
||||||
bool withAlpha,
|
const bool withAlpha,
|
||||||
Palette* palette,
|
Palette* palette,
|
||||||
PaletteOptimizerDelegate* delegate)
|
PaletteOptimizerDelegate* delegate)
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@ Image* convert_pixel_format(
|
|||||||
const Image* image,
|
const Image* image,
|
||||||
Image* new_image,
|
Image* new_image,
|
||||||
PixelFormat pixelFormat,
|
PixelFormat pixelFormat,
|
||||||
DitheringMethod ditheringMethod,
|
DitheringAlgorithm ditheringAlgorithm,
|
||||||
const RgbMap* rgbmap,
|
const RgbMap* rgbmap,
|
||||||
const Palette* palette,
|
const Palette* palette,
|
||||||
bool is_background,
|
bool is_background,
|
||||||
@ -94,7 +94,7 @@ Image* convert_pixel_format(
|
|||||||
// RGB -> Indexed with ordered dithering
|
// RGB -> Indexed with ordered dithering
|
||||||
if (image->pixelFormat() == IMAGE_RGB &&
|
if (image->pixelFormat() == IMAGE_RGB &&
|
||||||
pixelFormat == IMAGE_INDEXED &&
|
pixelFormat == IMAGE_INDEXED &&
|
||||||
ditheringMethod == DitheringMethod::ORDERED) {
|
ditheringAlgorithm == DitheringAlgorithm::Ordered) {
|
||||||
BayerMatrix<8> matrix;
|
BayerMatrix<8> matrix;
|
||||||
OrderedDither dither;
|
OrderedDither dither;
|
||||||
dither.ditherRgbImageToIndexed(matrix, image, new_image, 0, 0, rgbmap, palette);
|
dither.ditherRgbImageToIndexed(matrix, image, new_image, 0, 0, rgbmap, palette);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Rener Library
|
// Aseprite Rener Library
|
||||||
// Copyright (c) 2001-2015 David Capello
|
// Copyright (c) 2001-2015, 2017 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -8,11 +8,10 @@
|
|||||||
#define RENDER_QUANTIZATION_H_INCLUDED
|
#define RENDER_QUANTIZATION_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "doc/dithering_method.h"
|
|
||||||
#include "doc/frame.h"
|
#include "doc/frame.h"
|
||||||
#include "doc/pixel_format.h"
|
#include "doc/pixel_format.h"
|
||||||
|
|
||||||
#include "render/color_histogram.h"
|
#include "render/color_histogram.h"
|
||||||
|
#include "render/dithering_algorithm.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ namespace doc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
using namespace doc;
|
|
||||||
|
|
||||||
class PaletteOptimizerDelegate {
|
class PaletteOptimizerDelegate {
|
||||||
public:
|
public:
|
||||||
@ -35,34 +33,36 @@ namespace render {
|
|||||||
|
|
||||||
class PaletteOptimizer {
|
class PaletteOptimizer {
|
||||||
public:
|
public:
|
||||||
void feedWithImage(Image* image, bool withAlpha);
|
void feedWithImage(doc::Image* image, bool withAlpha);
|
||||||
void feedWithRgbaColor(color_t color);
|
void feedWithRgbaColor(doc::color_t color);
|
||||||
void calculate(Palette* palette, int maskIndex, PaletteOptimizerDelegate* delegate);
|
void calculate(doc::Palette* palette,
|
||||||
|
int maskIndex,
|
||||||
|
render::PaletteOptimizerDelegate* delegate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ColorHistogram<5, 6, 5, 5> m_histogram;
|
render::ColorHistogram<5, 6, 5, 5> m_histogram;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates a new palette suitable to quantize the given RGB sprite to Indexed color.
|
// Creates a new palette suitable to quantize the given RGB sprite to Indexed color.
|
||||||
Palette* create_palette_from_sprite(
|
doc::Palette* create_palette_from_sprite(
|
||||||
const Sprite* sprite,
|
const doc::Sprite* sprite,
|
||||||
frame_t fromFrame,
|
const doc::frame_t fromFrame,
|
||||||
frame_t toFrame,
|
const doc::frame_t toFrame,
|
||||||
bool withAlpha,
|
const bool withAlpha,
|
||||||
Palette* newPalette, // Can be NULL to create a new palette
|
doc::Palette* newPalette, // Can be NULL to create a new palette
|
||||||
PaletteOptimizerDelegate* delegate);
|
render::PaletteOptimizerDelegate* delegate);
|
||||||
|
|
||||||
// Changes the image pixel format. The dithering method is used only
|
// Changes the image pixel format. The dithering method is used only
|
||||||
// when you want to convert from RGB to Indexed.
|
// when you want to convert from RGB to Indexed.
|
||||||
Image* convert_pixel_format(
|
Image* convert_pixel_format(
|
||||||
const Image* src,
|
const doc::Image* src,
|
||||||
Image* dst, // Can be NULL to create a new image
|
doc::Image* dst, // Can be NULL to create a new image
|
||||||
PixelFormat pixelFormat,
|
doc::PixelFormat pixelFormat,
|
||||||
DitheringMethod ditheringMethod,
|
render::DitheringAlgorithm ditheringAlgorithm,
|
||||||
const RgbMap* rgbmap,
|
const doc::RgbMap* rgbmap,
|
||||||
const Palette* palette,
|
const doc::Palette* palette,
|
||||||
bool is_background,
|
bool is_background,
|
||||||
color_t new_mask_color);
|
doc::color_t new_mask_color);
|
||||||
|
|
||||||
} // namespace render
|
} // namespace render
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user