mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Use an internal ImageBuffer inside Mask class
This commit is contained in:
parent
709d23606a
commit
65da03d181
@ -48,14 +48,18 @@ Mask* load_msk_file(const char* filename)
|
||||
|
||||
// Animator Pro MSK format
|
||||
if ((size == orig_size) && (magic == 0x9500)) {
|
||||
int x, y;
|
||||
|
||||
fclose(f);
|
||||
|
||||
// Just load an Animator Pro PIC file
|
||||
int x, y;
|
||||
base::UniquePtr<Image> image(load_pic_file(filename, &x, &y, NULL));
|
||||
if (image != NULL && (image->pixelFormat() == IMAGE_BITMAP))
|
||||
mask = new Mask(x, y, image.release());
|
||||
|
||||
if (image != NULL && (image->pixelFormat() == IMAGE_BITMAP)) {
|
||||
mask = new Mask();
|
||||
mask->replace(gfx::Rect(x, y, image->width(), image->height()));
|
||||
mask->bitmap()->copy(image, 0, 0, 0, 0, image->width(), image->height());
|
||||
mask->shrink();
|
||||
}
|
||||
}
|
||||
// Animator MSK format
|
||||
else if (orig_size == 8000) {
|
||||
|
@ -32,14 +32,6 @@ Mask::Mask(const Mask& mask)
|
||||
copyFrom(&mask);
|
||||
}
|
||||
|
||||
Mask::Mask(int x, int y, Image* bitmap)
|
||||
: Object(ObjectType::Mask)
|
||||
, m_freeze_count(0)
|
||||
, m_bounds(x, y, bitmap->width(), bitmap->height())
|
||||
, m_bitmap(bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
Mask::~Mask()
|
||||
{
|
||||
ASSERT(m_freeze_count == 0);
|
||||
@ -141,8 +133,7 @@ void Mask::replace(const gfx::Rect& bounds)
|
||||
m_bounds = bounds;
|
||||
|
||||
delete m_bitmap;
|
||||
m_bitmap = Image::create(IMAGE_BITMAP, bounds.w, bounds.h);
|
||||
|
||||
m_bitmap = Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer);
|
||||
clear_image(m_bitmap, 1);
|
||||
}
|
||||
|
||||
@ -369,7 +360,7 @@ void Mask::reserve(const gfx::Rect& bounds)
|
||||
|
||||
if (!m_bitmap) {
|
||||
m_bounds = bounds;
|
||||
m_bitmap = Image::create(IMAGE_BITMAP, bounds.w, bounds.h);
|
||||
m_bitmap = Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer);
|
||||
clear_image(m_bitmap, 0);
|
||||
}
|
||||
else {
|
||||
|
@ -8,10 +8,11 @@
|
||||
#define DOC_MASK_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "gfx/rect.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/image_buffer.h"
|
||||
#include "doc/object.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "gfx/rect.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -22,7 +23,6 @@ namespace doc {
|
||||
public:
|
||||
Mask();
|
||||
Mask(const Mask& mask);
|
||||
Mask(int x, int y, Image* bitmap);
|
||||
virtual ~Mask();
|
||||
|
||||
virtual int getMemSize() const override;
|
||||
@ -103,6 +103,7 @@ namespace doc {
|
||||
std::string m_name; // Mask name
|
||||
gfx::Rect m_bounds; // Region bounds
|
||||
Image* m_bitmap; // Bitmapped image mask
|
||||
ImageBufferPtr m_buffer; // Buffer used in m_bitmap
|
||||
};
|
||||
|
||||
} // namespace doc
|
||||
|
Loading…
x
Reference in New Issue
Block a user