Gosu
Public Member Functions | List of all members
Gosu::Image Class Reference

Provides functionality for drawing rectangular images. More...

Public Member Functions

 Image ()
 Creates an empty image. It will have a width and height of 0, and not contain anything. More...
 
 Image (const std::string &filename, unsigned image_flags=IF_SMOOTH)
 Loads an image from a given filename. More...
 
 Image (const std::string &filename, unsigned src_x, unsigned src_y, unsigned src_width, unsigned src_height, unsigned image_flags=IF_SMOOTH)
 Loads a portion of the the image at the given filename. More...
 
 Image (const Bitmap &source, unsigned image_flags=IF_SMOOTH)
 Converts the given bitmap into an image. More...
 
 Image (const Bitmap &source, unsigned src_x, unsigned src_y, unsigned src_width, unsigned src_height, unsigned image_flags=IF_SMOOTH)
 Converts a portion of the given bitmap into an image. More...
 
 Image (std::unique_ptr< ImageData > &&data)
 Creates an Image from a user-supplied instance of the ImageData interface. More...
 
unsigned width () const
 
unsigned height () const
 
void draw (double x, double y, ZPos z, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const
 Draws the image so its upper left corner is at (x; y). More...
 
void draw_mod (double x, double y, ZPos z, double scale_x, double scale_y, Color c1, Color c2, Color c3, Color c4, AlphaMode mode=AM_DEFAULT) const
 Like draw(), but with modulation colors for all four corners. More...
 
void draw_rot (double x, double y, ZPos z, double angle, double center_x=0.5, double center_y=0.5, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const
 Draws the image rotated by the given angle so that its rotation center is at (x; y). More...
 
ImageDatadata () const
 Provides access to the underlying image data object. More...
 

Detailed Description

Provides functionality for drawing rectangular images.

Definition at line 15 of file Image.hpp.

Constructor & Destructor Documentation

◆ Image() [1/6]

Gosu::Image::Image ( )

Creates an empty image. It will have a width and height of 0, and not contain anything.

◆ Image() [2/6]

Gosu::Image::Image ( const std::string &  filename,
unsigned  image_flags = IF_SMOOTH 
)
explicit

Loads an image from a given filename.

A color key of #ff00ff is automatically applied to BMP image files. For more flexibility, use the corresponding constructor that uses a Bitmap object.

◆ Image() [3/6]

Gosu::Image::Image ( const std::string &  filename,
unsigned  src_x,
unsigned  src_y,
unsigned  src_width,
unsigned  src_height,
unsigned  image_flags = IF_SMOOTH 
)

Loads a portion of the the image at the given filename.

A color key of #ff00ff is automatically applied to BMP image files. For more flexibility, use the corresponding constructor that uses a Bitmap object.

◆ Image() [4/6]

Gosu::Image::Image ( const Bitmap source,
unsigned  image_flags = IF_SMOOTH 
)
explicit

Converts the given bitmap into an image.

◆ Image() [5/6]

Gosu::Image::Image ( const Bitmap source,
unsigned  src_x,
unsigned  src_y,
unsigned  src_width,
unsigned  src_height,
unsigned  image_flags = IF_SMOOTH 
)

Converts a portion of the given bitmap into an image.

◆ Image() [6/6]

Gosu::Image::Image ( std::unique_ptr< ImageData > &&  data)
explicit

Creates an Image from a user-supplied instance of the ImageData interface.

Member Function Documentation

◆ data()

ImageData& Gosu::Image::data ( ) const

Provides access to the underlying image data object.

◆ draw()

void Gosu::Image::draw ( double  x,
double  y,
ZPos  z,
double  scale_x = 1,
double  scale_y = 1,
Color  c = Color::WHITE,
AlphaMode  mode = AM_DEFAULT 
) const

Draws the image so its upper left corner is at (x; y).

◆ draw_mod()

void Gosu::Image::draw_mod ( double  x,
double  y,
ZPos  z,
double  scale_x,
double  scale_y,
Color  c1,
Color  c2,
Color  c3,
Color  c4,
AlphaMode  mode = AM_DEFAULT 
) const

Like draw(), but with modulation colors for all four corners.

◆ draw_rot()

void Gosu::Image::draw_rot ( double  x,
double  y,
ZPos  z,
double  angle,
double  center_x = 0.5,
double  center_y = 0.5,
double  scale_x = 1,
double  scale_y = 1,
Color  c = Color::WHITE,
AlphaMode  mode = AM_DEFAULT 
) const

Draws the image rotated by the given angle so that its rotation center is at (x; y).

Note that this is different from how all the other drawing functions work!

Parameters
angleSee Math.hpp for an explanation of how Gosu interprets angles.
center_xRelative horizontal position of the rotation center on the image. 0 is the left border, 1 is the right border, 0.5 is the center (and default).
center_ySee center_x.

◆ height()

unsigned Gosu::Image::height ( ) const

◆ width()

unsigned Gosu::Image::width ( ) const

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