X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fimage.h;h=15685c606e98353bf92d00c701c8f756f00b1fe2;hb=d7686e3867e3c68cec0d3767a21f9d2408383085;hp=bc7151b1250ba1dee336439350589027b6540363;hpb=cc728fda1325c5358f3ec177d31621b5688371fe;p=libs%2Fgui.git diff --git a/source/graphics/image.h b/source/graphics/image.h index bc7151b..15685c6 100644 --- a/source/graphics/image.h +++ b/source/graphics/image.h @@ -3,44 +3,49 @@ #include #include +#include +#include "mspgui_api.h" #include "pixelformat.h" namespace Msp { namespace Graphics { -class unsupported_image_format: public std::runtime_error -{ -public: - unsupported_image_format(const std::string &w): std::runtime_error(w) { } - virtual ~unsupported_image_format() throw() { } -}; +class ImageLoader; -class bad_image_data: public std::runtime_error +class MSPGUI_API Image { public: - bad_image_data(const std::string &w): std::runtime_error(w) { } - virtual ~bad_image_data() throw() { } -}; - - -class Image -{ -public: - struct Private; + struct Data + { + PixelFormat fmt = RGB; + unsigned width = 0; + unsigned height = 0; + unsigned stride = 0; + char *owned_pixels = nullptr; + char *pixels = nullptr; + + Data() = default; + Data(const Data &); + Data &operator=(const Data &); + ~Data(); + }; private: - Private *priv; + Data data; public: - Image(); - ~Image(); - void load_file(const std::string &); - void load_memory(const void *, unsigned); - PixelFormat get_format() const; - unsigned get_width() const; - unsigned get_height() const; - const void *get_data() const; + void load_io(IO::Seekable &); + void load(ImageLoader &); + void load_into(ImageLoader &, void *); + void load_headers(ImageLoader &); + + PixelFormat get_format() const { return data.fmt; } + unsigned get_width() const { return data.width; } + unsigned get_height() const { return data.height; } + unsigned get_stride() const { return data.stride; } + DEPRECATED const void *get_data() const { return data.pixels; } + const void *get_pixels() const { return data.pixels; } }; } // namespace Graphics