mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Small ImageData code cleanup.
This commit is contained in:
@@ -46,23 +46,19 @@ CompressedMemory::~CompressedMemory()
|
||||
}
|
||||
|
||||
CompressedSlice::CompressedSlice(PixelFormat format, int width, int height, CompressedMemory *memory, size_t offset, size_t size)
|
||||
: memory(memory)
|
||||
: ImageDataBase(format, width, height)
|
||||
, memory(memory)
|
||||
, offset(offset)
|
||||
, dataSize(size)
|
||||
{
|
||||
this->format = format;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
CompressedSlice::CompressedSlice(const CompressedSlice &s)
|
||||
: memory(s.memory)
|
||||
: ImageDataBase(s.getFormat(), s.getWidth(), s.getHeight())
|
||||
, memory(s.memory)
|
||||
, offset(s.offset)
|
||||
, dataSize(s.dataSize)
|
||||
{
|
||||
this->format = s.getFormat();
|
||||
this->width = s.getWidth();
|
||||
this->height = s.getHeight();
|
||||
}
|
||||
|
||||
CompressedSlice::~CompressedSlice()
|
||||
|
||||
@@ -32,19 +32,17 @@ namespace image
|
||||
love::Type ImageData::type("ImageData", &Data::type);
|
||||
|
||||
ImageData::ImageData(Data *data)
|
||||
: ImageDataBase(PIXELFORMAT_UNKNOWN, 0, 0)
|
||||
{
|
||||
decode(data);
|
||||
}
|
||||
|
||||
ImageData::ImageData(int width, int height, PixelFormat format)
|
||||
: ImageDataBase(format, width, height)
|
||||
{
|
||||
if (!validPixelFormat(format))
|
||||
throw love::Exception("Unsupported pixel format for ImageData");
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->format = format;
|
||||
|
||||
create(width, height, format);
|
||||
|
||||
// Set to black/transparency.
|
||||
@@ -52,14 +50,11 @@ ImageData::ImageData(int width, int height, PixelFormat format)
|
||||
}
|
||||
|
||||
ImageData::ImageData(int width, int height, PixelFormat format, void *data, bool own)
|
||||
: ImageDataBase(format, width, height)
|
||||
{
|
||||
if (!validPixelFormat(format))
|
||||
throw love::Exception("Unsupported pixel format for ImageData");
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->format = format;
|
||||
|
||||
if (own)
|
||||
this->data = (unsigned char *) data;
|
||||
else
|
||||
@@ -67,11 +62,8 @@ ImageData::ImageData(int width, int height, PixelFormat format, void *data, bool
|
||||
}
|
||||
|
||||
ImageData::ImageData(const ImageData &c)
|
||||
: ImageDataBase(c.format, c.width, c.height)
|
||||
{
|
||||
width = c.width;
|
||||
height = c.height;
|
||||
format = c.format;
|
||||
|
||||
create(width, height, format, c.getData());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace love
|
||||
namespace image
|
||||
{
|
||||
|
||||
ImageDataBase::ImageDataBase()
|
||||
: format(PIXELFORMAT_UNKNOWN)
|
||||
, width(0)
|
||||
, height(0)
|
||||
ImageDataBase::ImageDataBase(PixelFormat format, int width, int height)
|
||||
: format(format)
|
||||
, width(width)
|
||||
, height(height)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ class ImageDataBase : public Data
|
||||
{
|
||||
public:
|
||||
|
||||
ImageDataBase();
|
||||
virtual ~ImageDataBase() {}
|
||||
|
||||
PixelFormat getFormat() const;
|
||||
@@ -45,6 +44,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
ImageDataBase(PixelFormat format, int width, int height);
|
||||
|
||||
PixelFormat format;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
Reference in New Issue
Block a user