mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-17 07:10:36 +00:00
Optimize CompressedImage to get only bitmap information
When we create a CompressedImage from a Brush image, we want to know what pixels are != the mask color, just to generate the PointShape (we don't care the specific color of the scaneline/each pixel, that information is used in the "ink processing" step).
This commit is contained in:
parent
57156bddb7
commit
c5e79bb940
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
void preparePointShape(ToolLoop* loop) override {
|
void preparePointShape(ToolLoop* loop) override {
|
||||||
m_brush = loop->getBrush();
|
m_brush = loop->getBrush();
|
||||||
m_compressedImage.reset(new CompressedImage(m_brush->image()));
|
m_compressedImage.reset(new CompressedImage(m_brush->image(), false));
|
||||||
m_firstPoint = true;
|
m_firstPoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,27 +14,33 @@
|
|||||||
|
|
||||||
namespace doc {
|
namespace doc {
|
||||||
|
|
||||||
CompressedImage::CompressedImage(const Image* image)
|
CompressedImage::CompressedImage(const Image* image, bool diffColors)
|
||||||
: m_image(image)
|
: m_image(image)
|
||||||
{
|
{
|
||||||
color_t mask = image->maskColor();
|
color_t c1, c2, mask = image->maskColor();
|
||||||
|
|
||||||
for (int y=0; y<image->height(); ++y) {
|
for (int y=0; y<image->height(); ++y) {
|
||||||
Scanline scanline(y);
|
Scanline scanline(y);
|
||||||
|
|
||||||
for (int x=0; x<image->width(); ++x) {
|
for (int x=0; x<image->width(); ) {
|
||||||
scanline.color = get_pixel(image, x, y);
|
c1 = get_pixel(image, x, y);
|
||||||
|
if (c1 != mask) {
|
||||||
if (scanline.color != mask) {
|
scanline.color = c1;
|
||||||
scanline.x = x;
|
scanline.x = x;
|
||||||
|
|
||||||
for (; x<image->width(); ++x)
|
for (++x; x<image->width(); ++x) {
|
||||||
if (!get_pixel(image, x, y))
|
c2 = get_pixel(image, x, y);
|
||||||
|
|
||||||
|
if ((diffColors && c1 != c2) ||
|
||||||
|
(!diffColors && c2 == mask))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
scanline.w = x - scanline.x;
|
scanline.w = x - scanline.x;
|
||||||
m_scanlines.push_back(scanline);
|
m_scanlines.push_back(scanline);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
++x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,11 @@ namespace doc {
|
|||||||
typedef std::vector<Scanline> Scanlines;
|
typedef std::vector<Scanline> Scanlines;
|
||||||
typedef Scanlines::const_iterator const_iterator;
|
typedef Scanlines::const_iterator const_iterator;
|
||||||
|
|
||||||
CompressedImage(const Image* image);
|
// If diffColors is true, it generates one Scanline instance for
|
||||||
|
// each different color. If it's false, it generates a scanline
|
||||||
|
// for each row of consecutive pixels different than the mask
|
||||||
|
// color.
|
||||||
|
CompressedImage(const Image* image, bool diffColors);
|
||||||
|
|
||||||
const_iterator begin() const { return m_scanlines.begin(); }
|
const_iterator begin() const { return m_scanlines.begin(); }
|
||||||
const_iterator end() const { return m_scanlines.end(); }
|
const_iterator end() const { return m_scanlines.end(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user