mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 03:32:48 +00:00
Avoid to create an optimized palette for RGB images if the same loading process creates one.
+ Added Palette:isBlack member function.
This commit is contained in:
parent
b82ec86994
commit
53896f9bfb
@ -394,7 +394,7 @@ FileOp *fop_to_save_sprite(Sprite *sprite)
|
||||
else
|
||||
fop->filename = fop->sprite->getFilename();
|
||||
|
||||
/* configure output format? */
|
||||
// Configure output format?
|
||||
if (fop->format->support(FILE_SUPPORT_GET_FORMAT_OPTIONS)) {
|
||||
FormatOptions* format_options = fop->format->getFormatOptions(fop);
|
||||
|
||||
@ -540,7 +540,8 @@ void fop_operate(FileOp *fop)
|
||||
// Set the frames range
|
||||
fop->sprite->setTotalFrames(frame);
|
||||
|
||||
// Set the frames range
|
||||
// Sets special options from the specific format (e.g. BMP
|
||||
// file can contain the number of bits per pixel).
|
||||
fop->sprite->setFormatOptions(fop->seq.format_options);
|
||||
}
|
||||
}
|
||||
@ -566,7 +567,9 @@ void fop_operate(FileOp *fop)
|
||||
fop->sprite->setFilename(fop->filename.c_str());
|
||||
|
||||
// Creates a suitable palette for RGB images
|
||||
if (fop->sprite->getImgType() == IMAGE_RGB) {
|
||||
if (fop->sprite->getImgType() == IMAGE_RGB &&
|
||||
fop->sprite->getPalettes().size() <= 1 &&
|
||||
fop->sprite->getPalette(0)->isBlack()) {
|
||||
Palette* palette = quantization::create_palette_from_rgb(fop->sprite);
|
||||
|
||||
fop->sprite->resetPalettes();
|
||||
|
@ -128,6 +128,15 @@ int Palette::countDiff(const Palette* other, int* from, int* to) const
|
||||
return diff;
|
||||
}
|
||||
|
||||
bool Palette::isBlack() const
|
||||
{
|
||||
for (size_t c=0; c<m_colors.size(); ++c)
|
||||
if (getEntry(c) != _rgba(0, 0, 0, 255))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Palette::makeBlack()
|
||||
{
|
||||
std::fill(m_colors.begin(), m_colors.end(), _rgba(0, 0, 0, 255));
|
||||
|
@ -78,7 +78,10 @@ public:
|
||||
|
||||
int countDiff(const Palette* other, int* from, int* to) const;
|
||||
|
||||
// Returns true if the palette is completelly black.
|
||||
bool isBlack() const;
|
||||
void makeBlack();
|
||||
|
||||
void makeHorzRamp(int from, int to);
|
||||
void makeVertRamp(int from, int to, int columns);
|
||||
void makeRectRamp(int from, int to, int columns);
|
||||
|
Loading…
x
Reference in New Issue
Block a user