X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fimage.h;h=3f8f556e85a42fa88e5f7f886918037b3143434e;hb=3c5bbaeadb33d288c0f9e487b52904b7ed7e4319;hp=137f856f21f5736d40dbecae6275a26919c42536;hpb=1ca709deba08e55d95066be564a8fd43a321af19;p=libs%2Fgui.git diff --git a/source/graphics/image.h b/source/graphics/image.h index 137f856..3f8f556 100644 --- a/source/graphics/image.h +++ b/source/graphics/image.h @@ -3,45 +3,48 @@ #include #include -#include +#include #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 bad_image_data: public std::runtime_error -{ -public: - bad_image_data(const std::string &w): std::runtime_error(w) { } - virtual ~bad_image_data() throw() { } -}; - +class ImageLoader; 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_io(IO::Base &); - 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