Gorgon Game Engine
Image Class Reference

This resource contains images. More...

Inheritance diagram for Image:
[legend]

Public Member Functions

 Image ()=default
 
 Image (Graphics::Bitmap &&source)
 Assumes the given bitmap and converts it to a resource. More...
 
virtual void Discard () override
 This function discards image data. More...
 
GID::Type GetCompression () const
 Returns the compression mode of this image resource. More...
 
virtual GID::Type GetGID () const override
 This function shall return Gorgon ID of this resource. More...
 
bool IsLoaded () const
 Returns whether the image data is loaded. More...
 
bool Load ()
 Loads the image from the disk. This function requires image to be tied to a resource file. More...
 
Graphics::RectangularAnimationStorage MoveOut ()
 Moves this animation out as a generic value type animation. More...
 
Graphics::Bitmap MoveOutAsBitmap ()
 Moves the data out of resource system. Use Prepare and Discard before moving to avoid data duplication. More...
 
virtual void Prepare () override
 This function prepares image for drawing. More...
 
void SetCompression (GID::Type compression)
 Changes the compression mode. More...
 
- Public Member Functions inherited from Bitmap
 Bitmap ()
 Default constructor will create an empty bitmap. More...
 
 Bitmap (Bitmap &&other)
 Move constructor. More...
 
 Bitmap (const Bitmap &)=delete
 Copy constructor is disabled. More...
 
 Bitmap (const Geometry::Size &size, Graphics::ColorMode mode=Graphics::ColorMode::RGBA)
 Creates an uninitialized image of the given size and color mode. More...
 
 Bitmap (Containers::Image &&imagedata)
 Move constructor. More...
 
 Bitmap (int width, int height, Graphics::ColorMode mode)
 
virtual ~Bitmap ()
 Destroys image data. More...
 
void Assign (Byte *newdata)
 Assigns the image to the copy of the given data. More...
 
void Assign (Byte *newdata, const Geometry::Size &size, Graphics::ColorMode mode)
 Assigns the image to the copy of the given data. More...
 
void Assign (const Containers::Image &image)
 Assigns the given image as the data of this image resource. More...
 
void Assume (Byte *newdata)
 Assumes the ownership of the given data. More...
 
void Assume (Byte *newdata, const Geometry::Size &size, Graphics::ColorMode mode)
 Assumes the ownership of the given data. More...
 
void Assume (Containers::Image &image)
 Assumes the contents of the given image as image data. More...
 
Bitmap Blur (float amount, int windowsize=-1) const
 Creates the blurred version of this image as a new separate image. More...
 
void Clear ()
 Cleans the contents of the buffer by setting every byte it contains to 0. More...
 
BitmapCreateAnimation (bool=false) const override
 This function should create and animation and depending on the create parameter, it should create its own timer. More...
 
BitmapCreateAnimation (Gorgon::Animation::ControllerBase &) const override
 This function should create a new animation with the given controller and if owner parameter is set to true, it should assume ownership of the controller. More...
 
std::vector< TextureImageCreateAtlasImages (std::vector< Geometry::Bounds > boundaries) const
 Creates images from the given atlas image and map. More...
 
std::vector< Geometry::BoundsCreateLinearAtlas (Containers::Collection< const Bitmap > list, AtlasMargin margins=None)
 Assumes all image heights are similar and all images have same color mode. More...
 
virtual void DeleteAnimation () const override
 if used as animation, this object will not be deleted More...
 
void Destroy ()
 
Bitmap Duplicate () const
 Duplicates this image. More...
 
bool ExportBMP (const std::string &filename)
 Exports the data of the image resource to a bitmap file. More...
 
bool ExportBMP (std::ostream &out)
 Exports the data of the image resource to a bitmap file. More...
 
bool ExportJPG (const std::string &filename, int quality=90)
 Exports the data of the image resource to a JPG file. More...
 
bool ExportJPG (std::ostream &out, int quality=90)
 Exports the data of the image resource to a JPG file. More...
 
bool ExportPNG (const std::string &filename)
 Exports the data of the image resource to a PNG file. More...
 
bool ExportPNG (std::ostream &out)
 Exports the data of the image resource to a PNG file. More...
 
void ForAllPixels (std::function< void(Byte &)> fn, int channel)
 Loops through all pixels of the image, giving the specified channel value to your function. More...
 
void ForAllPixels (std::function< void(Byte)> fn, int channel) const
 Loops through all pixels of the image, giving the specified channel value to your function. More...
 
void ForAllPixels (std::function< void(int, int)> fn) const
 Loops through all pixels of the image, giving coordinates to your function. More...
 
void ForAllPixels (std::function< void(int, int, int)> fn) const
 Loops through all pixels and channels of the image, giving coordinates to your function. More...
 
void ForAllValues (std::function< void(Byte &)> fn)
 Loops through all channels of all pixels of the image. More...
 
void ForAllValues (std::function< void(Byte)> fn) const
 Loops through all channels of all pixels of the image. More...
 
bool ForPixels (std::function< bool(Byte &)> fn, int channel)
 Loops through all pixels of the image, giving the specified channel value to your function. More...
 
bool ForPixels (std::function< bool(Byte)> fn, int channel) const
 Loops through all pixels of the image, giving the specified channel value to your function. More...
 
bool ForPixels (std::function< bool(int, int)> fn) const
 Loops through all pixels of the image, giving coordinates to your function. More...
 
bool ForPixels (std::function< bool(int, int, int)> fn) const
 Loops through all pixels of the image, giving coordinates to your function. More...
 
Byte Get (const Geometry::Point &p, Byte def, unsigned component=0) const
 Provides access to the given component in x and y coordinates. More...
 
Byte Get (const Geometry::Point &p, unsigned component=0) const
 Provides access to the given component in x and y coordinates. More...
 
Byte GetAlphaAt (Geometry::Point p) const
 Returns the alpha at the given location. More...
 
Byte GetAlphaAt (int x, int y) const
 Returns the alpha at the given location. More...
 
int GetAlphaIndex () const
 Returns the index of alpha channel. Value of -1 denotes no alpha channel. More...
 
int GetChannelsPerPixel () const
 Returns the bytes occupied by a single pixel of this image. More...
 
Containers::ImageGetData () const
 Returns the data attached to this bitmap. If no data is present, this function throws. More...
 
int GetHeight () const
 Returns the height of the bitmap. More...
 
Graphics::ColorMode GetMode () const override
 Returns the color mode of the image. More...
 
RGBA GetRGBAAt (Geometry::Point p) const
 Returns the alpha at the given location. More...
 
RGBA GetRGBAAt (int x, int y) const
 Returns the alpha at the given location. More...
 
Geometry::Size GetSize () const override
 Returns the size of this image resource. More...
 
int GetWidth () const
 Returns the width of the bitmap. More...
 
void Grayscale (float ratio=1.0f, GrayscaleConversionMethod method=Luminance)
 Transforms this image to a grayscale image. More...
 
bool HasAlpha () const
 Returns if this image has alpha channel. More...
 
bool HasData () const
 Checks if this image resource has a data attached to it. More...
 
bool HasTexture () const
 Checks if this image resource has a texture attached to it. More...
 
bool Import (const std::string &filename)
 Imports an image file to become the new data of this image resource. More...
 
bool Import (std::istream &file)
 Imports an image file to become the new data of this image resource. More...
 
bool ImportBMP (const std::string &filename)
 Imports a BMP file to become the new data of this image resource. More...
 
bool ImportBMP (std::istream &file)
 Imports a BMP file to become the new data of this image resource. More...
 
bool ImportJPEG (const std::string &filename)
 Imports a JPEG file to become the new data of this image resource. More...
 
bool ImportJPEG (std::istream &file)
 Imports a JPEG file to become the new data of this image resource. More...
 
bool ImportPNG (const std::string &filename)
 Imports a PNG file to become the new data of this image resource. More...
 
bool ImportPNG (std::istream &file)
 Imports a PNG file to become the new data of this image resource. More...
 
bool IsEmpty () const
 Checks if this bitmap is empty: either 0x0 in size or completely transparent. More...
 
bool IsEmpty (Geometry::Bounds bounds) const
 Checks if the given region of this bitmap is completely transparent. More...
 
virtual auto MoveOutProvider () -> decltype(*this) override
 This function moves this animation provider into a new provider. More...
 
Byteoperator() (const Geometry::Point &p, unsigned component=0)
 Provides access to the given component in x and y coordinates. More...
 
Byte operator() (const Geometry::Point &p, unsigned component=0) const
 Provides access to the given component in x and y coordinates. More...
 
Byteoperator() (int x, int y, unsigned component=0)
 Provides access to the given component in x and y coordinates. More...
 
Byte operator() (int x, int y, unsigned component=0) const
 Provides access to the given component in x and y coordinates. More...
 
Bitmapoperator= (Bitmap &&other)
 Move assignment. More...
 
Bitmapoperator= (Bitmap &)=delete
 Copy assignment is disabled. More...
 
Containers::Image ReleaseData ()
 Releases the image data. More...
 
Graphics::TextureImage ReleaseTexture ()
 Releases the texture held by this image. More...
 
void Resize (const Geometry::Size &size, Graphics::ColorMode mode=Graphics::ColorMode::RGBA)
 Resizes the image to the given size and color mode. More...
 
void Resize (int w, int h, Graphics::ColorMode mode=Graphics::ColorMode::RGBA)
 Resizes the image to the given size and color mode. More...
 
Graphics::Bitmap Rotate180 () const
 Rotates image data without any losses. More...
 
Graphics::Bitmap Rotate270 () const
 Rotates image data without any losses. More...
 
Graphics::Bitmap Rotate90 () const
 Rotates image data without any losses. More...
 
virtual void SetController (Gorgon::Animation::ControllerBase &) override
 Bitmap cannot be controlled. More...
 
void SetRGBAAt (Geometry::Point p, RGBA color)
 Sets the color at the given location to the specified RGBA value. More...
 
void SetRGBAAt (int x, int y, RGBA color)
 Sets the color at the given location to the specified RGBA value. More...
 
Bitmap Shadow (float amount, int windowsize=-1) const
 Creates a smooth drop shadow by using alpha channel of this image. More...
 
Bitmap Slice (Geometry::Bounds bounds) const
 Returns a new bitmap containing a slice of this bitmap. More...
 
void StripAlpha ()
 This function removes transparency information from the image. More...
 
void StripRGB ()
 This function removes color channels, leaving only alpha channel. More...
 
virtual void Swap (Bitmap &other)
 Swaps two images, mostly used for move constructor,. More...
 
Geometry::Margin Trim ()
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions. More...
 
Geometry::Margin Trim (bool horizontal, bool vertical)
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions. More...
 
Geometry::Margin Trim (bool left, bool top, bool right, bool bottom)
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions. More...
 
Geometry::Margin Trim (Geometry::Bounds bounds)
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty potions. More...
 
Geometry::Margin Trim (Geometry::Bounds bounds, bool horizontal, bool vertical)
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty potions. More...
 
Geometry::Margin Trim (Geometry::Bounds bounds, bool left, bool top, bool right, bool bottom)
 Trims the empty parts of the image, alpha channel = 0 is used to determine empty potions. More...
 
Graphics::Bitmap ZoomMultiple (int factor) const
 Zooms the image while preserving the colors. More...
 
- Public Member Functions inherited from RectangularAnimationProvider
int GetHeight () const
 
int GetWidth () const
 
- Public Member Functions inherited from AnimationProvider
virtual ~AnimationProvider ()
 
- Public Member Functions inherited from Provider
virtual ~Provider ()
 Virtual destructor. More...
 
- Public Member Functions inherited from RectangularDrawable
const Geometry::Size CalculateSize (const Geometry::Size &area) const
 Calculates the adjusted size of this drawable depending on the given area. More...
 
const Geometry::Size CalculateSize (const SizeController &controller, const Geometry::Size &area) const
 Calculates the adjusted size of this drawable depending on the given area and controller. More...
 
const Geometry::Size CalculateSize (const SizeController &controller, int w=-1, int h=-1) const
 Calculates the adjusted size of this drawable depending on the given area and controller. More...
 
const Geometry::Size CalculateSize (int w=-1, int h=-1) const
 Calculates the adjusted size of this drawable depending on the given area. More...
 
void Draw (TextureTarget &target, const Geometry::Point &p, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, const Geometry::Sizef &size, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, const Geometry::Sizef &size, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, float w, float h, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, float w, float h, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f)) const
 Draw the object to the target by specifying coordinates for four corners. More...
 
void Draw (TextureTarget &target, float x, float y, const Geometry::Sizef &size, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x, float y, const Geometry::Sizef &size, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x, float y, float w, float h, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x, float y, float w, float h, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x, float y, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const Geometry::Pointf &t1, const Geometry::Pointf &t2, const Geometry::Pointf &t3, const Geometry::Pointf &t4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4, RGBAf color=RGBAf(1.f)) const
 Draws the object with the given screen and texture coordinates. More...
 
void Draw (TextureTarget &target, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, RGBAf color=RGBAf(1.f)) const
 Draw the object to the target by specifying coordinates for four corners. More...
 
void Draw (TextureTarget &target, int x, int y, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void DrawIn (TextureTarget &target, const Geometry::Point &p, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, const Geometry::Point &p, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, const Geometry::Pointf &p, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, const Geometry::Pointf &p, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, const Geometry::Rectangle &r, RGBAf color=RGBAf(1.f)) const
 Draw in the given area. More...
 
void DrawIn (TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color=RGBAf(1.f)) const
 Draw in the given area. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Point &p, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area with the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Point &p, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Pointf &p, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area with the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Pointf &p, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Rectangle &r, RGBAf color=RGBAf(1.f)) const
 Draw in the given area according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, const Geometry::Rectanglef &r, RGBAf color=RGBAf(1.f)) const
 Draw in the given area according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, float x, float y, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates with the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, int x, int y, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, int x, int y, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates with the given size according to the given controller. More...
 
void DrawIn (TextureTarget &target, const SizeController &controller, RGBAf color=RGBAf(1.f)) const
 Draw to fill the given target according to the given controller. More...
 
void DrawIn (TextureTarget &target, float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, float x, float y, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, int x, int y, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, int x, int y, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area. More...
 
void DrawIn (TextureTarget &target, RGBAf color=RGBAf(1.f)) const
 Draw to fill the given target. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Point &p, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Point &p, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Pointf &p, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Pointf &p, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Rectangle &r, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, const Geometry::Rectanglef &r, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, float x, float y, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, int x, int y, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawIn (TextureTarget &target, Tiling tiling, int x, int y, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draws the object to the target using the given tiling information. More...
 
void DrawRotated (TextureTarget &target, const Geometry::Point &p, float angle, const Geometry::Pointf &origin=Geometry::Point(0, 0), RGBAf color=RGBAf(1.f)) const
 Draw the object rotated to the given angle in radians, full C++11 support will enable the use of 90deg like qualifiers. More...
 
void DrawRotated (TextureTarget &target, const Geometry::Point &p, float angle, RGBAf color) const
 Draw the object rotated to the given angle in radians, full C++11 support will enable the use of 90deg like qualifiers. More...
 
void DrawRotated (TextureTarget &target, int x, int y, float angle, float oX, float oY, RGBAf color=RGBAf(1.f)) const
 Draw the object rotated to the given angle in radians, full C++11 support will enable the use of 90deg like qualifiers. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Point &p, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Point &p, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Pointf &p, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Pointf &p, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Rectangle &r, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, float x, float y, float w, float h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, int x, int y, const Geometry::Size &size, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
void DrawStretched (TextureTarget &target, int x, int y, int w, int h, RGBAf color=RGBAf(1.f)) const
 Draw to the given area by stretching object to fit. More...
 
int GetHeight () const
 Returns the height of the drawable. More...
 
const Geometry::Size GetSize () const
 Returns the size of this object. More...
 
int GetWidth () const
 Returns the width of the drawable. More...
 
- Public Member Functions inherited from Drawable
virtual ~Drawable ()
 
void Draw (TextureTarget &target, const Geometry::Point &p, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, const Geometry::Pointf &p, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, float x, float y, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
void Draw (TextureTarget &target, int x, int y, RGBAf color=RGBAf(1.f)) const
 Draw to the given coordinates. More...
 
- Public Member Functions inherited from TextureSource
bool IsPartial () const
 Returns whether this texture uses only a part of the GL::Texture. More...
 
- Public Member Functions inherited from Base
 Base (bool create=false)
 This constructor creates a new controller depending on the create parameter. More...
 
 Base (const Base &base)
 Copies the animation. More...
 
 Base (ControllerBase &controller)
 Sets the controller for this animation to the given controller. More...
 
virtual ControllerBaseGetController () const
 Returns the controller of this animation. More...
 
virtual bool HasController () const
 Returns whether this animation has a controller. More...
 
virtual void RemoveController ()
 Removes the controller of this animation. More...
 
- Public Member Functions inherited from AnimationStorage
Graphics::RectangularAnimationStorage MoveOut ()
 Moves this animation out as a generic value type animation. More...
 
- Public Member Functions inherited from Base
 Base ()
 Default constructor. More...
 
const Containers::Collection< Base >::ConstIterator begin () const
 Allows easy iteration through range based fors. More...
 
const Containers::Collection< Base >::ConstIterator cbegin () const
 Beginning of children. More...
 
const Containers::Collection< Base >::ConstIterator cend () const
 End of children. More...
 
bool DeleteResource ()
 Safely deletes the resource. More...
 
const Containers::Collection< Base >::ConstIterator end () const
 Allows easy iteration through range based fors. More...
 
virtual SGuid GetGuid () const
 Returns the guid of the object. More...
 
const std::string & GetName () const
 Returns the name of this object. More...
 
BaseGetParent () const
 Returns the parent. If no parent set, this function throws std::runtime_error. More...
 
BaseGetParentPtr () const
 Returns the pointer to the parent. This function may return nullptr. More...
 
const BaseGetRoot () const
 Returns the root of this resource. More...
 
bool HasParent () const
 Returns whether this object has a parent. More...
 
virtual bool IsEqual (const SGuid &guid) const
 This function tests whether this object has the given SGuid. More...
 
virtual void Resolve (File &file)
 This function shall resolve links or similar constructs. More...
 
void Save (Writer &writer)
 Saves this object into the given writer. The writer should be open prior to this call. More...
 
virtual void SetGuid (SGuid guid)
 Changes the guid of the object. More...
 
virtual void SetName (const std::string &name)
 Sets the name of the object. More...
 

Static Public Member Functions

static ImageLoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
 This function loads a image resource from the given file. More...
 
static void SaveThis (Writer &writer, const Graphics::Bitmap &bmp, GID::Type type=GID::Image)
 This function can be used to save a bitmap as image resource without modifying it. More...
 

Protected Member Functions

virtual ~Image ()
 
virtual Graphics::RectangularAnimationStorage animmoveout () override
 
bool load (std::shared_ptr< Reader > reader, unsigned long size, bool forceload)
 Loads the image from the data stream. More...
 
void loaded ()
 
void save (Writer &writer) const override
 
- Protected Member Functions inherited from Bitmap
int GetDuration () const override
 Returns the duration of the animation if it is a known apriori. More...
 
Geometry::Size getsize () const override
 Should return the exact size of this object. More...
 
bool Progress (unsigned &) override
 When used as animation, an image is always persistent and it never finishes. More...
 
- Protected Member Functions inherited from Image
virtual Geometry::Size calculatesize (const Geometry::Size &s) const override
 This function should return the size of the object when it is requested to be drawn in the given area. More...
 
virtual Geometry::Size calculatesize (const SizeController &controller, const Geometry::Size &s) const override
 This function should return the size of the object when it is requested to be drawn in the given area. More...
 
virtual void draw (TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color) const override
 This method should draw to object inside the given quad with the given texture coordinates. More...
 
virtual void draw (TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color) const override
 This function should draw the object inside the given quad. More...
 
virtual void drawin (TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color) const override
 This function should draw the object to the target area. More...
 
virtual void drawin (TextureTarget &target, const SizeController &controller, const Geometry::Rectanglef &r, RGBAf color) const override
 This function should draw this drawable inside the given rectangle according to the given controller. More...
 
virtual void drawstretched (TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color) const override
 This function should draw the object to the target area. More...
 
- Protected Member Functions inherited from RectangularDrawable
virtual void draw (TextureTarget &target, const Geometry::Pointf &p, RGBAf color) const override
 This function should draw the object to the given point. More...
 
- Protected Member Functions inherited from Base
virtual ~Base ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from Texture
 Texture ()
 Default constructor, creates an empty texture. More...
 
 Texture (const Containers::Image &image)
 This constructor creates a new texture from the given Image. More...
 
 Texture (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Regular, full texture constructor. More...
 
 Texture (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Atlas constructor, specifies a region of the texture. More...
 
 Texture (Texture &&other)
 Moves a texture. More...
 
 Texture (Texture &other)
 Copies a texture. This newly created texture will not assume ownership. More...
 
virtual ~Texture ()
 
void Assume (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Sets the texture to the given id with the given size. More...
 
void Assume (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Sets the texture to the given id with the given size. More...
 
void CreateEmpty (const Geometry::Size &size, ColorMode mode)
 Create an empty texture. More...
 
void Destroy ()
 Remove the texture from this object. If this object is the owner of the texture, then it is destroyed. More...
 
virtual const Geometry::PointfGetCoordinates () const override final
 Returns the coordinates of the texture to be used. Declared final to allow inlining. More...
 
virtual GL::Texture GetID () const override final
 Returns GL::Texture to be drawn. Declared final to allow inlining. More...
 
virtual Geometry::Size GetImageSize () const override final
 Returns the size of the texture in pixels. Declared final to allow inlining. More...
 
ColorMode GetMode () const override
 
GL::Texture Release ()
 Releases the texture id that might be owned by this object without destroying it. More...
 
void Set (const Containers::Image &image)
 Sets the texture to the given id with the given size. More...
 
void Set (GL::Texture id)
 Sets the texture to the given id without any modification to size or color mode. More...
 
void Set (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Sets the texture to the given id with the given size. More...
 
void Set (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Sets the texture to the given id with the given size. More...
 
void Swap (Texture &other)
 Swaps two textures. More...
 
- Protected Member Functions inherited from Base
virtual ~Base ()
 Destructor, Always children gets destroyed first. More...
 
void destroychildren ()
 Destroys the children of this resource. More...
 
void setparenttonullptr (Base &base)
 Sets the parent of an object to nullptr, provides access. More...
 

Protected Attributes

GID::Type compression
 Compression mode. More...
 
unsigned long entrypoint
 Entry point of this resource within the physical file. More...
 
bool isloaded
 Whether this image resource is loaded or not. More...
 
std::shared_ptr< Readerreader
 Used to handle late loading. More...
 
- Protected Attributes inherited from Bitmap
Containers::Imagedata
 Container for the image data, could be null indicating its discarded. More...
 
Geometry::Size size
 Size of the texture. More...
 
- Protected Attributes inherited from Base
ControllerBasecontroller
 Controller of this animation. More...
 
- Protected Attributes inherited from Texture
Geometry::Pointf coordinates [4]
 Readily calculated texture coordinates of the image. More...
 
GL::Texture id
 GL texture id. More...
 
ColorMode mode
 Color mode of the texture, necessary to choose correct texture. More...
 
bool owner
 Whether this object owns this texture. More...
 
Geometry::Size size
 Size of the texture. More...
 
- Protected Attributes inherited from Base
Containers::Collection< Basechildren
 Child objects that this resource object have. More...
 
SGuid guid
 SGuid to identify this resource object. More...
 
std::string name
 Name of this resource object, may not be loaded. More...
 
Baseparent
 Immediate parent of this resource. More...
 
const Baseroot
 Root of this resource. More...
 

Additional Inherited Members

- Public Types inherited from Bitmap
using AnimationType = Bitmap
 
enum  AtlasMargin { None, Zero, Repeat, Wrap }
 
enum  GrayscaleConversionMethod { Luminance, Average, Maximum, Minimum }
 
- Public Types inherited from RectangularAnimationProvider
using AnimationType = RectangularAnimation
 
- Public Types inherited from AnimationProvider
using AnimationType = Animation
 
- Public Types inherited from Provider
using AnimationType = Base
 
- Public Attributes inherited from Base
const Containers::Collection< Base > & Children
 The children this object have. More...
 
unsigned long refcount
 INTERNAL, Reference count, used in linking mechanism. More...
 
- Static Protected Attributes inherited from TextureSource
static const Geometry::Pointf fullcoordinates [4]
 Coordinates that selects the entire texture to be used. More...
 

Detailed Description

This resource contains images.

It allows draw, load, import, export functionality. An image resource may work without its data buffer. In order to be drawn, an image object should be prepared. Both data and texture might be released from the image resource. This allows safe destruction of the file tree without destroying the necessary information.

Constructor & Destructor Documentation

◆ Image() [1/2]

Image ( )
default

◆ Image() [2/2]

Image ( Graphics::Bitmap &&  source)

Assumes the given bitmap and converts it to a resource.

References Bitmap::Swap().

◆ ~Image()

virtual ~Image ( )
protectedvirtual

Member Function Documentation

◆ animmoveout()

◆ Discard()

virtual void Discard ( )
overridevirtual

This function discards image data.

Reimplemented from Bitmap.

◆ GetCompression()

GID::Type GetCompression ( ) const

Returns the compression mode of this image resource.

References Image::compression.

◆ GetGID()

virtual GID::Type GetGID ( ) const
overridevirtual

This function shall return Gorgon ID of this resource.

Implements Base.

References Gorgon::Resource::GID::Image.

◆ IsLoaded()

bool IsLoaded ( ) const

Returns whether the image data is loaded.

Data loading is a valid information in only resource context. If this image is created manually, it is always considered loaded even if no data is set for it.

References Image::isloaded.

◆ Load()

bool Load ( )

Loads the image from the disk. This function requires image to be tied to a resource file.

References Image::entrypoint, Image::isloaded, Image::load(), Image::loaded(), Image::reader, and Bitmap::size.

◆ load()

◆ loaded()

void loaded ( )
protected

References Image::reader.

◆ LoadResource()

Image * LoadResource ( std::weak_ptr< File file,
std::shared_ptr< Reader reader,
unsigned long  size 
)
static

This function loads a image resource from the given file.

References Image::Image(), Image::reader, and Bitmap::size.

◆ MoveOut()

Moves this animation out as a generic value type animation.

References AnimationStorage::animmoveout().

◆ MoveOutAsBitmap()

Graphics::Bitmap MoveOutAsBitmap ( )

Moves the data out of resource system. Use Prepare and Discard before moving to avoid data duplication.

◆ Prepare()

virtual void Prepare ( )
overridevirtual

This function prepares image for drawing.

Reimplemented from Bitmap.

◆ save()

◆ SaveThis()

void SaveThis ( Writer writer,
const Graphics::Bitmap bmp,
GID::Type  type = GID::Image 
)
static

This function can be used to save a bitmap as image resource without modifying it.

If given bitmap is a resource save function of that resource is used instead. If the area of the bitmap is greater than 400 pixel it will be saved as PNG.

◆ SetCompression()

void SetCompression ( GID::Type  compression)

Changes the compression mode.

It only works if this image is saved along with a file. Currently only GID::None and GID::PNG works.

References Image::compression.

Member Data Documentation

◆ compression

GID::Type compression
protected

Compression mode.

◆ entrypoint

unsigned long entrypoint
protected

Entry point of this resource within the physical file.

This value is stored for late loading purposes

◆ isloaded

bool isloaded
protected

Whether this image resource is loaded or not.

◆ reader

std::shared_ptr<Reader> reader
protected

Used to handle late loading.


The documentation for this class was generated from the following files: