blah/include/blah/images/image.h

42 lines
966 B
C
Raw Normal View History

2020-08-26 15:38:01 +08:00
#pragma once
#include <blah/math/color.h>
#include <blah/math/rectI.h>
#include <blah/math/point.h>
namespace Blah
{
class Stream;
class Image
2020-08-26 15:38:01 +08:00
{
public:
2020-08-26 15:38:01 +08:00
int width = 0;
int height = 0;
Color* pixels = nullptr;
Image();
Image(Stream& stream);
Image(const char* file);
Image(int width, int height);
Image(const Image& src);
Image& operator=(const Image& src);
Image(Image&& src) noexcept;
Image& operator=(Image&& src) noexcept;
~Image();
void from_stream(Stream& stream);
void dispose();
void premultiply();
void set_pixels(const RectI& rect, Color* data);
bool save_png(const char* file) const;
bool save_png(Stream& stream) const;
bool save_jpg(const char* file, int quality) const;
bool save_jpg(Stream& stream, int quality) const;
void get_pixels(Color* dest, const Point& destPos, const Point& destSize, RectI sourceRect);
Image get_sub_image(const RectI& sourceRect);
private:
bool m_stbi_ownership;
2020-08-26 15:38:01 +08:00
};
}