![]() |
Gorgon Game Engine
|
This object contains an bitmap image. More...
Public Types | |
using | AnimationType = Bitmap |
enum | AtlasMargin { None, Zero, Repeat, Wrap } |
enum | GrayscaleConversionMethod { Luminance, Average, Maximum, Minimum } |
![]() | |
using | AnimationType = RectangularAnimation |
![]() | |
using | AnimationType = Animation |
![]() | |
using | AnimationType = Base |
Public Member Functions | |
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... | |
Bitmap & | CreateAnimation (bool=false) const override |
This function should create and animation and depending on the create parameter, it should create its own timer. More... | |
Bitmap & | CreateAnimation (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< TextureImage > | CreateAtlasImages (std::vector< Geometry::Bounds > boundaries) const |
Creates images from the given atlas image and map. More... | |
std::vector< Geometry::Bounds > | CreateLinearAtlas (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 () |
virtual void | Discard () |
This function discards image data. More... | |
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::Image & | GetData () 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... | |
Byte & | operator() (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... | |
Byte & | operator() (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... | |
Bitmap & | operator= (Bitmap &&other) |
Move assignment. More... | |
Bitmap & | operator= (Bitmap &)=delete |
Copy assignment is disabled. More... | |
virtual void | Prepare () |
This function prepares image for drawing. 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... | |
![]() | |
int | GetHeight () const |
int | GetWidth () const |
![]() | |
virtual | ~AnimationProvider () |
![]() | |
virtual | ~Provider () |
Virtual destructor. More... | |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
bool | IsPartial () const |
Returns whether this texture uses only a part of the GL::Texture. More... | |
![]() | |
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 ControllerBase & | GetController () 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... | |
Protected Member Functions | |
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... | |
![]() | |
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... | |
![]() | |
virtual void | draw (TextureTarget &target, const Geometry::Pointf &p, RGBAf color) const override |
This function should draw the object to the given point. More... | |
![]() | |
virtual | ~Base () |
Virtual destructor. More... | |
![]() | |
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::Pointf * | GetCoordinates () 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 Attributes | |
Containers::Image * | data |
Container for the image data, could be null indicating its discarded. More... | |
Geometry::Size | size |
Size of the texture. More... | |
![]() | |
ControllerBase * | controller |
Controller of this animation. More... | |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
static const Geometry::Pointf | fullcoordinates [4] |
Coordinates that selects the entire texture to be used. More... | |
This object contains an bitmap image.
It allows draw, load, import, export functionality. An image 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.
Some operations are inplace while others create new Bitmaps. This is done for performance reasons and both can be used to create a new image: newimage = cur.Duplicate.Grayscale();
or inplace: cur = cur.Blur();
using AnimationType = Bitmap |
enum AtlasMargin |
Bitmap | ( | ) |
Default constructor will create an empty bitmap.
|
explicit |
Creates an uninitialized image of the given size and color mode.
Prepare function should be called to be able to draw this image.
References Texture::mode, and Bitmap::size.
Bitmap | ( | int | width, |
int | height, | ||
Graphics::ColorMode | mode | ||
) |
Move constructor.
References Bitmap::Swap().
Bitmap | ( | Containers::Image && | imagedata | ) |
Move constructor.
References Bitmap::data, and basic_Image< T_ >::Swap().
|
virtual |
Destroys image data.
References Bitmap::data.
void Assign | ( | Byte * | newdata | ) |
Assigns the image to the copy of the given data.
Ownership of the given data is not transferred. If the given data is not required elsewhere, consider using Assume function. The size and color mode of the image stays the same. The given data should have the size of width*height*Graphics::GetBytesPerPixel(mode)*sizeof(Byte). This function does not perform any checks for the data size while copying it. Notice that changing data does not prepare the data to be drawn, a separate call to Prepare function is necessary.
References basic_Image< T_ >::Assign(), and Bitmap::data.
void Assign | ( | Byte * | newdata, |
const Geometry::Size & | size, | ||
Graphics::ColorMode | mode | ||
) |
Assigns the image to the copy of the given data.
Ownership of the given data is not transferred. If the given data is not required elsewhere, consider using Assume function. This variant performs resize and copy at the same time. The given data should have the size of width*height*Graphics::GetBytesPerPixel(mode)*sizeof(Byte). This function does not perform any checks for the data size while copying it. If width or height is 0, the newdata is not accessed and this method effectively Destroys the current image. In this case, both width and height should be specified as 0. Notice that changing data does not prepare the data to be drawn, a separate call to Prepare function is necessary.
References basic_Image< T_ >::Assign(), Bitmap::data, Texture::mode, and Bitmap::size.
void Assign | ( | const Containers::Image & | image | ) |
Assigns the given image as the data of this image resource.
Notice that changing data does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::data, and basic_Image< T_ >::Duplicate().
void Assume | ( | Byte * | newdata | ) |
Assumes the ownership of the given data.
The size and color mode of the image stays the same. The given data should have the size of width*height*Graphics::GetBytesPerPixel(mode)*sizeof(Byte). This function does not perform any checks for the data size while assuming it. Notice that assuming data does not prepare the data to be drawn, a separate call to Prepare function is necessary.
References basic_Image< T_ >::Assume(), and Bitmap::data.
void Assume | ( | Byte * | newdata, |
const Geometry::Size & | size, | ||
Graphics::ColorMode | mode | ||
) |
Assumes the ownership of the given data.
This variant changes the size and color mode of the image. The given data should have the size of width*height*Graphics::GetBytesPerPixel(mode)*sizeof(Byte). This function does not perform any checks for the data size while assuming it. newdata could be nullptr however, in this case width, height should be 0. mode is not assumed to be ColorMode::Invalid while the image is empty, therefore it could be specified as any value. Notice that assuming data does not prepare the data to be drawn, a separate call to Prepare function is necessary.
References basic_Image< T_ >::Assume(), Bitmap::data, Texture::mode, and Bitmap::size.
void Assume | ( | Containers::Image & | image | ) |
Assumes the contents of the given image as image data.
The given parameter is moved from and will become an empty image. Notice that assuming data does not prepare the data to be drawn, a separate call to Prepare function is necessary.
References Bitmap::data.
Bitmap Blur | ( | float | amount, |
int | windowsize = -1 |
||
) | const |
Creates the blurred version of this image as a new separate image.
This function creates another image since it is not possible to apply blur in place. You may use move assignment to modify the original img = img.Blur(1.2);
amount | is variance of the blur. This value is measured in pixels however, image will have blurred edges more than the given amount. |
windowsize | is the size of the effect window. If the value is -1, the window size is automatically determined. Reducing window size will speed up this function. |
void Clear | ( | ) |
Cleans the contents of the buffer by setting every byte it contains to 0.
References ASSERT, basic_Image< T_ >::Clear(), and Bitmap::data.
|
overridevirtual |
This function should create and animation and depending on the create parameter, it should create its own timer.
Implements RectangularAnimationProvider.
|
overridevirtual |
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.
Implements RectangularAnimationProvider.
std::vector< TextureImage > CreateAtlasImages | ( | std::vector< Geometry::Bounds > | boundaries | ) | const |
Creates images from the given atlas image and map.
Prepares every image as well. This requires image to be prepared. Texture images can be passed around as value, but it is best to avoid that.
References TextureSource::GetID(), Bitmap::GetMode(), and Bitmap::GetSize().
std::vector< Geometry::Bounds > CreateLinearAtlas | ( | Containers::Collection< const Bitmap > | list, |
AtlasMargin | margins = None |
||
) |
Assumes all image heights are similar and all images have same color mode.
If there is colormode problem, this function will throw. You can either have duplicate or move your collection to this function as it needs to modify the collection on the run. Moving would be more efficient. Margin can be useful if the images would be drawn resized. Unless a margin correction method is selected, textures will bleed into each other. Currently only None and Empty modes are supported.
References Gorgon::Input::Keyboard::Keycodes::C, basic_Image< T_ >::Clear(), Bitmap::data, Bitmap::GetChannelsPerPixel(), Bitmap::GetHeight(), Collection< T_ >::GetSize(), Bitmap::GetSize(), Bitmap::GetWidth(), basic_Size< T_ >::Height, Texture::mode, Gorgon::Input::Keyboard::Keycodes::N, Bitmap::Resize(), Bitmap::size, basic_Size< T_ >::Width, and Bitmap::Zero.
|
overridevirtual |
if used as animation, this object will not be deleted
Reimplemented from Base.
void Destroy | ( | ) |
References Bitmap::data, and Texture::Destroy().
|
virtual |
Bitmap Duplicate | ( | ) | const |
Duplicates this image.
Only the data portion is duplicated. No other information is transferred to the image. Omitted information includes resource related data and texture related data. Therefore, before drawing the newly duplicated image, it should be prepared for drawing to work.
References Bitmap::Assign(), and Bitmap::data.
bool ExportBMP | ( | const std::string & | filename | ) |
Exports the data of the image resource to a bitmap file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. All color modes are supported in BMP, however, saving and loading the file may change the color mode. Regardless of this change when drawn, bitmap will appear the same on the screen.
References ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, basic_Image< T_ >::ExportBMP(), and basic_Image< T_ >::GetSize().
bool ExportBMP | ( | std::ostream & | out | ) |
Exports the data of the image resource to a bitmap file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. All color modes are supported in BMP, however, saving and loading the file may change the color mode. Regardless of this change when drawn, bitmap will appear the same on the screen.
References ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, basic_Image< T_ >::ExportBMP(), and basic_Image< T_ >::GetSize().
bool ExportJPG | ( | const std::string & | filename, |
int | quality = 90 |
||
) |
Exports the data of the image resource to a JPG file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported by PNG encoding. JPG encoding allows: RGB and Grayscale. Quality is between 0 and 100.
References ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, JPEG::Encode(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), Gorgon::Graphics::Grayscale, Gorgon::Encoding::Jpg, and Gorgon::Graphics::RGB.
bool ExportJPG | ( | std::ostream & | out, |
int | quality = 90 |
||
) |
Exports the data of the image resource to a JPG file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported by PNG encoding. JPG encoding allows: RGB and Grayscale. Quality is between 0 and 100.
References ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, JPEG::Encode(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), Gorgon::Graphics::Grayscale, Gorgon::Encoding::Jpg, and Gorgon::Graphics::RGB.
bool ExportPNG | ( | const std::string & | filename | ) |
Exports the data of the image resource to a PNG file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported by PNG encoding. PNG encoding allows: RGB, RGBA, Grayscale, Grayscale alpha. Additionally, Alpha only images are saved as grayscale alpha.
References Gorgon::Graphics::Alpha, ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, PNG::Encode(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), Gorgon::Graphics::Grayscale, Gorgon::Graphics::Invalid, Gorgon::Encoding::Png, Gorgon::Graphics::RGB, and Gorgon::Graphics::RGBA.
bool ExportPNG | ( | std::ostream & | out | ) |
Exports the data of the image resource to a PNG file.
This function requires image data to be present. If image data is already discarded, there is no way to retrieve it. May throw if color mode is not supported by PNG encoding. PNG encoding allows: RGB, RGBA, Grayscale, Grayscale alpha. Additionally, Alpha only images are saved as grayscale alpha.
References Gorgon::Graphics::Alpha, ASSERT, basic_Size< T_ >::Cells(), Bitmap::data, PNG::Encode(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), Gorgon::Graphics::Grayscale, Gorgon::Graphics::Invalid, Gorgon::Encoding::Png, Gorgon::Graphics::RGB, and Gorgon::Graphics::RGBA.
void ForAllPixels | ( | std::function< void(Byte &)> | fn, |
int | channel | ||
) |
Loops through all pixels of the image, giving the specified channel value to your function.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
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.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
void ForAllPixels | ( | std::function< void(int, int)> | fn | ) | const |
Loops through all pixels of the image, giving coordinates to your function.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
void ForAllPixels | ( | std::function< void(int, int, int)> | fn | ) | const |
Loops through all pixels and channels of the image, giving coordinates to your function.
References Bitmap::data, Bitmap::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
void ForAllValues | ( | std::function< void(Byte &)> | fn | ) |
Loops through all channels of all pixels of the image.
References Bitmap::data, Bitmap::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
void ForAllValues | ( | std::function< void(Byte)> | fn | ) | const |
Loops through all channels of all pixels of the image.
References Bitmap::data, Bitmap::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
bool ForPixels | ( | std::function< bool(Byte &)> | fn, |
int | channel | ||
) |
Loops through all pixels of the image, giving the specified channel value to your function.
If you return false, looping will stop and the function will return false.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
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.
If you return false, looping will stop and the function will return false.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
bool ForPixels | ( | std::function< bool(int, int)> | fn | ) | const |
Loops through all pixels of the image, giving coordinates to your function.
If you return false, looping will stop and the function will return false.
References Bitmap::data, basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
bool ForPixels | ( | std::function< bool(int, int, int)> | fn | ) | const |
Loops through all pixels of the image, giving coordinates to your function.
If you return false, looping will stop and the function will return false.
References Bitmap::data, Bitmap::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), and basic_Image< T_ >::GetWidth().
Byte Get | ( | const Geometry::Point & | p, |
Byte | def, | ||
unsigned | component = 0 |
||
) | const |
Provides access to the given component in x and y coordinates.
This function returns 0 if the given coordinates are out of bounds. This function works slower than the () operator.
References Bitmap::data, and basic_Image< T_ >::Get().
Byte Get | ( | const Geometry::Point & | p, |
unsigned | component = 0 |
||
) | const |
Provides access to the given component in x and y coordinates.
This function returns 0 if the given coordinates are out of bounds. This function works slower than the () operator.
References Bitmap::data, and basic_Image< T_ >::Get().
Byte GetAlphaAt | ( | Geometry::Point | p | ) | const |
Returns the alpha at the given location.
If the given location does not exits this function will return 0. If there is no alpha channel, image is assumed to be opaque.
References Bitmap::GetAlphaAt(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.
Byte GetAlphaAt | ( | int | x, |
int | y | ||
) | const |
Returns the alpha at the given location.
If the given location does not exits this function will return 0. If there is no alpha channel, image is assumed to be opaque.
References Bitmap::data, and basic_Image< T_ >::GetAlphaAt().
int GetAlphaIndex | ( | ) | const |
Returns the index of alpha channel. Value of -1 denotes no alpha channel.
References Bitmap::data, and basic_Image< T_ >::GetAlphaIndex().
int GetChannelsPerPixel | ( | ) | const |
Returns the bytes occupied by a single pixel of this image.
References Bitmap::data, and basic_Image< T_ >::GetChannelsPerPixel().
Containers::Image& GetData | ( | ) | const |
Returns the data attached to this bitmap. If no data is present, this function throws.
References Bitmap::data.
|
overrideprotectedvirtual |
Returns the duration of the animation if it is a known apriori.
If the animation can be progressed infinitely, if it is possible to derive optimal duration, it should be returned. In case when it is impossible to determine the duration, return 0.
Implements Base.
int GetHeight | ( | ) | const |
Returns the height of the bitmap.
If texture is prepared, the height of the texture is returned otherwise height of the bitmap is returned
References Bitmap::GetSize(), and basic_Size< T_ >::Height.
|
overridevirtual |
Returns the color mode of the image.
Implements TextureSource.
References Bitmap::data, basic_Image< T_ >::GetMode(), Texture::GetMode(), and Texture::id.
RGBA GetRGBAAt | ( | Geometry::Point | p | ) | const |
Returns the alpha at the given location.
If the given location does not exits this function will return 0. If there is no alpha channel, image is assumed to be opaque.
References Bitmap::GetRGBAAt(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.
RGBA GetRGBAAt | ( | int | x, |
int | y | ||
) | const |
Returns the alpha at the given location.
If the given location does not exits this function will return 0. If there is no alpha channel, image is assumed to be opaque.
References Bitmap::data, and basic_Image< T_ >::GetRGBAAt().
|
overridevirtual |
Returns the size of this image resource.
It is possible for an image to become unsynchronized due to a modification to the image data. Image texture size takes precedence if this happens.
Implements RectangularAnimationProvider.
References Bitmap::data, Texture::GetImageSize(), basic_Image< T_ >::GetSize(), and Texture::id.
|
overrideprotectedvirtual |
Should return the exact size of this object.
Reimplemented from Image.
References Bitmap::GetSize().
int GetWidth | ( | ) | const |
Returns the width of the bitmap.
If texture is prepared, the width of the texture is returned otherwise width of the bitmap is returned
References Bitmap::GetSize(), and basic_Size< T_ >::Width.
void Grayscale | ( | float | ratio = 1.0f , |
GrayscaleConversionMethod | method = Luminance |
||
) |
Transforms this image to a grayscale image.
This function has no effect if the image is already grayscale
ratio | of the transformation. If ratio is 0, image is not modified. If the ratio is 1, image will be transformed into fully grayscale image. Values between 0 and 1 will desaturate the image depending on the given ratio. If the ratio is 1, color mode of the image will be modified to Grayscale or Grayscale_Alpha. |
method | to be used for transformation. Default is Luminance which mimic human vision |
References Gorgon::Graphics::Alpha, Bitmap::Assume(), RGBA::Blend(), basic_Image< T_ >::ChangeMode(), Bitmap::data, basic_Image< T_ >::GetHeight(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), basic_Image< T_ >::GetWidth(), Gorgon::Graphics::Grayscale, Bitmap::HasAlpha(), Gorgon::Graphics::Invalid, Bitmap::Luminance, Texture::mode, Gorgon::Graphics::RGB, and Gorgon::Graphics::RGBA.
bool HasAlpha | ( | ) | const |
Returns if this image has alpha channel.
References Bitmap::data, and basic_Image< T_ >::HasAlpha().
bool HasData | ( | ) | const |
Checks if this image resource has a data attached to it.
References Bitmap::data.
bool HasTexture | ( | ) | const |
Checks if this image resource has a texture attached to it.
References Texture::id.
bool Import | ( | const std::string & | filename | ) |
Imports an image file to become the new data of this image resource.
Type of the image is determined from the extension or if extension is not present from file signature. Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::ImportBMP(), Bitmap::ImportJPEG(), Bitmap::ImportPNG(), Gorgon::IO::ReadUInt32(), and Gorgon::String::ToLower().
bool Import | ( | std::istream & | file | ) |
Imports an image file to become the new data of this image resource.
Filetype is determined from file signature. Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::ImportBMP(), Bitmap::ImportJPEG(), Bitmap::ImportPNG(), and Gorgon::IO::ReadUInt32().
bool ImportBMP | ( | const std::string & | filename | ) |
Imports a BMP file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::data, Bitmap::Destroy(), and basic_Image< T_ >::ImportBMP().
bool ImportBMP | ( | std::istream & | file | ) |
Imports a BMP file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::data, Bitmap::Destroy(), and basic_Image< T_ >::ImportBMP().
bool ImportJPEG | ( | const std::string & | filename | ) |
Imports a JPEG file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::data, JPEG::Decode(), Bitmap::Destroy(), and Gorgon::Encoding::Jpg.
bool ImportJPEG | ( | std::istream & | file | ) |
Imports a JPEG file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary
References Bitmap::data, JPEG::Decode(), Bitmap::Destroy(), and Gorgon::Encoding::Jpg.
bool ImportPNG | ( | const std::string & | filename | ) |
Imports a PNG file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary. Returns true on success. False if file is not found. In other cases (eg. corrupt file), it will throw.
References Bitmap::data, PNG::Decode(), Bitmap::Destroy(), and Gorgon::Encoding::Png.
bool ImportPNG | ( | std::istream & | file | ) |
Imports a PNG file to become the new data of this image resource.
Notice that importing does not prepare the data to be drawn, a separate call to Prepare function is necessary. Returns true on success. False if file is not found. In other cases (eg. corrupt file), it will throw.
References Bitmap::data, PNG::Decode(), Bitmap::Destroy(), and Gorgon::Encoding::Png.
bool IsEmpty | ( | ) | const |
Checks if this bitmap is empty: either 0x0 in size or completely transparent.
References Bitmap::GetSize().
bool IsEmpty | ( | Geometry::Bounds | bounds | ) | const |
Checks if the given region of this bitmap is completely transparent.
References basic_Bounds< T_ >::Bottom, Bitmap::data, Bitmap::GetAlphaIndex(), basic_Bounds< T_ >::GetSize(), Bitmap::HasAlpha(), basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
|
overridevirtual |
This function moves this animation provider into a new provider.
Ownership of this new object belongs to the caller and this object could be destroyed safely.
Implements RectangularAnimationProvider.
Byte& operator() | ( | const Geometry::Point & | p, |
unsigned | component = 0 |
||
) |
Provides access to the given component in x and y coordinates.
This function performs bounds checking only on debug mode. Notice that changing a pixel does not prepare the new data to be drawn, a separate call to Prepare function is necessary.
References Bitmap::data.
Byte operator() | ( | const Geometry::Point & | p, |
unsigned | component = 0 |
||
) | const |
Provides access to the given component in x and y coordinates.
This function performs bounds checking only on debug mode.
References Bitmap::data.
Byte& operator() | ( | int | x, |
int | y, | ||
unsigned | component = 0 |
||
) |
Provides access to the given component in x and y coordinates.
This function performs bounds checking only on debug mode. Notice that changing a pixel does not prepare the new data to be drawn, a separate call to Prepare function is necessary.
References Bitmap::data.
Byte operator() | ( | int | x, |
int | y, | ||
unsigned | component = 0 |
||
) | const |
Provides access to the given component in x and y coordinates.
This function performs bounds checking only on debug mode.
References Bitmap::data.
Move assignment.
References Texture::Destroy(), Bitmap::Discard(), and Bitmap::Swap().
|
virtual |
This function prepares image for drawing.
Reimplemented in Image.
References Bitmap::data, and Texture::Set().
|
overrideprotectedvirtual |
When used as animation, an image is always persistent and it never finishes.
Implements Base.
Containers::Image ReleaseData | ( | ) |
Releases the image data.
The image data returned by this function is moved out. Data is passed by value, thus if it is not moved into a Containers::Image, it will be destroyed.
References ASSERT_DUMP, and Bitmap::data.
Graphics::TextureImage ReleaseTexture | ( | ) |
Releases the texture held by this image.
Texture is passed by value, thus if it is not moved into a Graphics::TextureImage, it will be destroyed.
References Bitmap::GetMode(), Texture::Release(), and Texture::size.
void Resize | ( | const Geometry::Size & | size, |
Graphics::ColorMode | mode = Graphics::ColorMode::RGBA |
||
) |
Resizes the image to the given size and color mode.
This function discards the contents of the image and does not perform any initialization.
References Bitmap::data, Texture::mode, basic_Image< T_ >::Resize(), and Bitmap::size.
void Resize | ( | int | w, |
int | h, | ||
Graphics::ColorMode | mode = Graphics::ColorMode::RGBA |
||
) |
Resizes the image to the given size and color mode.
This function discards the contents of the image and does not perform any initialization.
References Texture::mode, and Bitmap::Resize().
Graphics::Bitmap Rotate180 | ( | ) | const |
Rotates image data without any losses.
References ASSERT, Bitmap::data, Bitmap::ForAllPixels(), Bitmap::GetHeight(), Bitmap::GetMode(), Bitmap::GetSize(), and Bitmap::GetWidth().
Graphics::Bitmap Rotate270 | ( | ) | const |
Rotates image data without any losses.
References ASSERT, Bitmap::data, Bitmap::ForAllPixels(), Bitmap::GetHeight(), Bitmap::GetMode(), and Bitmap::GetWidth().
Graphics::Bitmap Rotate90 | ( | ) | const |
Rotates image data without any losses.
References ASSERT, Bitmap::data, Bitmap::ForAllPixels(), Bitmap::GetHeight(), Bitmap::GetMode(), and Bitmap::GetWidth().
|
overridevirtual |
void SetRGBAAt | ( | Geometry::Point | p, |
RGBA | color | ||
) |
Sets the color at the given location to the specified RGBA value.
If pixel does not exists, the call will be ignored.
References Bitmap::SetRGBAAt(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.
void SetRGBAAt | ( | int | x, |
int | y, | ||
RGBA | color | ||
) |
Sets the color at the given location to the specified RGBA value.
If pixel does not exists, the call will be ignored.
References Bitmap::data, and basic_Image< T_ >::SetRGBAAt().
Bitmap Shadow | ( | float | amount, |
int | windowsize = -1 |
||
) | const |
Creates a smooth drop shadow by using alpha channel of this image.
Resultant image has Grayscale_Alpha color mode. This function creates another image.
amount | is variance of the blur. This value is measured in pixels however, image will have blurred edges more than the given amount. |
windowsize | is the size of the effect window. If the value is -1, the window size is automatically determined. Reducing window size will speed up this function. |
Bitmap Slice | ( | Geometry::Bounds | bounds | ) | const |
Returns a new bitmap containing a slice of this bitmap.
References ASSERT, basic_Image< T_ >::CopyTo(), Bitmap::data, Bitmap::GetData(), Bitmap::GetMode(), and basic_Bounds< T_ >::GetSize().
void StripAlpha | ( | ) |
This function removes transparency information from the image.
References Gorgon::Graphics::Alpha, Bitmap::Assume(), Bitmap::data, Bitmap::GetAlphaIndex(), basic_Image< T_ >::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), basic_Image< T_ >::GetWidth(), and Bitmap::HasAlpha().
void StripRGB | ( | ) |
This function removes color channels, leaving only alpha channel.
References Gorgon::Graphics::Alpha, ASSERT, Bitmap::Assume(), Bitmap::data, Bitmap::GetAlphaIndex(), basic_Image< T_ >::GetHeight(), basic_Image< T_ >::GetSize(), basic_Image< T_ >::GetWidth(), and Bitmap::HasAlpha().
|
virtual |
Swaps two images, mostly used for move constructor,.
References Bitmap::data, Gorgon::swap(), and Texture::Swap().
Geometry::Margin Trim | ( | ) |
Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions.
Trimming is performed to all sides of the image. Trim operation will not be performed on empty images.
Geometry::Margin Trim | ( | bool | horizontal, |
bool | vertical | ||
) |
Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions.
Parameters control which sides of the image would be trimmed. Trim operation will not be performed on empty images.
References Bitmap::Trim().
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.
Parameters control which sides of the image would be trimmed. Trim operation will not be performed on empty images.
References ASSERT, Bitmap::Assume(), Bitmap::data, basic_Image< T_ >::GetChannelsPerPixel(), basic_Image< T_ >::GetHeight(), Bitmap::GetMode(), basic_Image< T_ >::GetSize(), Bitmap::GetSize(), basic_Image< T_ >::GetWidth(), and Bitmap::Trim().
Geometry::Margin Trim | ( | Geometry::Bounds | bounds | ) |
Trims the empty parts of the image, alpha channel = 0 is used to determine empty potions.
This variant performs the check within the specified region and thus suitable for atlas images. This trim operation will not actually modify the image.
References Bitmap::Trim().
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.
This variant performs the check within the specified region and thus suitable for atlas images. This trim operation will not actually modify the image.
References Bitmap::Trim().
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.
This variant performs the check within the specified region and thus suitable for atlas images. This trim operation will not actually modify the image.
References ASSERT, basic_Bounds< T_ >::Bottom, basic_Margin< T_ >::Bottom, Bitmap::data, Bitmap::GetAlphaIndex(), Bitmap::HasAlpha(), basic_Bounds< T_ >::Left, basic_Margin< T_ >::Left, basic_Bounds< T_ >::Right, basic_Margin< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Margin< T_ >::Top.
Graphics::Bitmap ZoomMultiple | ( | int | factor | ) | const |
Zooms the image while preserving the colors.
References ASSERT, Bitmap::data, Bitmap::ForAllPixels(), Bitmap::GetHeight(), Bitmap::GetMode(), and Bitmap::GetWidth().
|
protected |
Container for the image data, could be null indicating its discarded.
|
protected |
Size of the texture.