raylib-cpp
C++ object-oriented wrapper library for raylib.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
raylib::Image Class Reference

Public Member Functions

 Image ()
 
 Image (::Font font, const std::string &text, float fontSize, float spacing, ::Color tint)
 
 Image (::Image image)
 
 Image (::Texture2D texture)
 
 Image (const std::string &fileName)
 
 Image (const std::string &fileName, int *frames)
 
 Image (const std::string &fileName, int width, int height, int format, int headerSize)
 
 Image (const std::string &fileType, const unsigned char *fileData, int dataSize)
 
 Image (int width, int height, Color color=WHITE)
 
 ~Image ()
 
Image & AlphaCrop (float threshold)
 Crop image depending on alpha value. More...
 
Image & AlphaMask (Image alphaMask)
 Apply alpha mask to image. More...
 
Image & AlphaPremultiply ()
 Premultiply alpha channel. More...
 
Image & ClearBackground (::Color color=WHITE)
 Clear image background with given color. More...
 
Image & ColorBrightness (int brightness)
 Modify image color: brightness. More...
 
Image & ColorContrast (float contrast)
 Modify image color: contrast. More...
 
Image & ColorGrayscale ()
 Modify image color: grayscale. More...
 
Image & ColorInvert ()
 Modify image color: invert. More...
 
Image & ColorReplace (::Color color, ::Color replace)
 Modify image color: replace color. More...
 
Image & ColorTint (::Color color=WHITE)
 Modify image color: tint. More...
 
Image Copy ()
 Create an image duplicate (useful for transformations) More...
 
Image & Crop (::Rectangle crop)
 Crop an image to area defined by a rectangle. More...
 
Image & Crop (int offsetX, int offsetY, int newWidth, int newHeight)
 Crop an image to area defined by a rectangle. More...
 
Image & Dither (int rBpp, int gBpp, int bBpp, int aBpp)
 Dither image data to 16bpp or lower (Floyd-Steinberg dithering) More...
 
Image & Draw (const ::Image &src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint=WHITE)
 
Image & DrawCircle (::Vector2 center, int radius, ::Color color)
 
Image & DrawCircle (int centerX, int centerY, int radius, ::Color color)
 
Image & DrawLine (::Vector2 start, ::Vector2 end, ::Color color)
 
Image & DrawLine (int startPosX, int startPosY, int endPosX, int endPosY, ::Color color)
 
Image & DrawPixel (::Vector2 position, ::Color color)
 
Image & DrawPixel (int posX, int posY, ::Color color)
 Draw pixel within an image. More...
 
Image & DrawRectangle (::Rectangle rec, ::Color color=WHITE)
 
Image & DrawRectangle (int posX, int posY, int width, int height, ::Color color=WHITE)
 
Image & DrawRectangle (Vector2 position, Vector2 size, ::Color color=WHITE)
 
Image & DrawRectangleLines (::Rectangle rec, int thick, ::Color color)
 
Image & DrawText (::Font font, const std::string &text, ::Vector2 position, float fontSize, float spacing, ::Color tint=WHITE)
 
Image & DrawText (const std::string &text, ::Vector2 position, int fontSize, ::Color color=WHITE)
 
Image & DrawText (const std::string &text, int x, int y, int fontSize, ::Color color=WHITE)
 
bool Export (const std::string &fileName)
 Export image data to file, returns true on success. More...
 
bool ExportAsCode (const std::string &fileName)
 Export image as code file defining an array of bytes, returns true on success. More...
 
Image & FlipHorizontal ()
 Flip image horizontally. More...
 
Image & FlipVertical ()
 Flip image vertically. More...
 
Image & Format (int newFormat)
 Convert image data to desired format. More...
 
Image FromImage (::Rectangle rec)
 Create an image from another image piece. More...
 
Rectangle GetAlphaBorder (float threshold) const
 Get image alpha border rectangle. More...
 
void * GetData () const
 
int GetFormat () const
 
int GetHeight () const
 
int GetMipmaps () const
 
int GetWidth () const
 
void Load (const std::string &fileName)
 
void LoadAnim (const std::string &fileName, int *frames)
 
inline ::Color * LoadColors ()
 Load color data from image as a Color array (RGBA - 32bit) More...
 
void LoadFromMemory (const std::string &fileType, const unsigned char *fileData, int dataSize)
 
inline ::Color * LoadPalette (int maxPaletteSize, int *colorsCount)
 Load colors palette from image as a Color array (RGBA - 32bit) More...
 
void LoadRaw (const std::string &fileName, int width, int height, int format, int headerSize)
 
inline ::Texture2D LoadTexture ()
 Load texture from image data. More...
 
Image & Mipmaps ()
 Generate all mipmap levels for a provided image. More...
 
 operator::Texture2D ()
 Load texture from image data. More...
 
Image & operator= (const ::Image &image)
 
Image & operator= (const Image &image)
 
Image & Resize (int newWidth, int newHeight)
 Resize and image to new size. More...
 
Image & ResizeCanvas (int newWidth, int newHeight, int offsetX, int offsetY, Color color)
 Resize canvas and fill with color. More...
 
Image & ResizeNN (int newWidth, int newHeight)
 Resize and image to new size using Nearest-Neighbor scaling algorithm. More...
 
Image & RotateCCW ()
 Rotate image counter-clockwise 90deg. More...
 
Image & RotateCW ()
 Rotate image clockwise 90deg. More...
 
void SetData (void *value)
 
void SetFormat (int value)
 
void SetHeight (int value)
 
void SetMipmaps (int value)
 
void SetWidth (int value)
 
Image & ToPOT (Color fillColor)
 Convert image to POT (power-of-two) More...
 
void Unload ()
 

Static Public Member Functions

static Image GenCellular (int width, int height, int tileSize)
 Generate image: cellular algorithm. More...
 
static Image GenChecked (int width, int height, int checksX, int checksY, Color col1, Color col2)
 Generate image: checked. More...
 
static Image GenColor (int width, int height, Color color)
 Generate image: plain color. More...
 
static Image GenGradientH (int width, int height, Color left, Color right)
 Generate image: horizontal gradient. More...
 
static Image GenGradientRadial (int width, int height, float density, Color inner, Color outer)
 Generate image: radial gradient. More...
 
static Image GenGradientV (int width, int height, Color top, Color bottom)
 Generate image: vertical gradient. More...
 
static Image GenPerlinNoise (int width, int height, int offsetX, int offsetY, float scale)
 Generate image: perlin noise. More...
 
static Image GenWhiteNoise (int width, int height, float factor)
 Generate image: white noise. More...
 
static Image GetScreenData ()
 Get pixel data from screen buffer and return an Image (screenshot) More...
 
static Image Text (::Font font, std::string text, float fontSize, float spacing, ::Color tint)
 
static Image Text (std::string text, int fontSize, Color color)
 

Protected Member Functions

void set (::Image image)
 

Detailed Description

Definition at line 34 of file Image.hpp.

Constructor & Destructor Documentation

◆ Image() [1/9]

raylib::Image::Image ( )
inline

Definition at line 36 of file Image.hpp.

Referenced by GetScreenData().

◆ Image() [2/9]

raylib::Image::Image ( ::Image  image)
inline

Definition at line 37 of file Image.hpp.

References set().

◆ Image() [3/9]

raylib::Image::Image ( const std::string &  fileName)
inline

Definition at line 40 of file Image.hpp.

References Load().

◆ Image() [4/9]

raylib::Image::Image ( const std::string &  fileName,
int  width,
int  height,
int  format,
int  headerSize 
)
inline

Definition at line 43 of file Image.hpp.

References LoadRaw().

◆ Image() [5/9]

raylib::Image::Image ( const std::string &  fileName,
int *  frames 
)
inline

Definition at line 46 of file Image.hpp.

References LoadAnim().

◆ Image() [6/9]

raylib::Image::Image ( const std::string &  fileType,
const unsigned char *  fileData,
int  dataSize 
)
inline

Definition at line 49 of file Image.hpp.

References LoadFromMemory().

◆ Image() [7/9]

raylib::Image::Image ( ::Texture2D  texture)
inline

Definition at line 52 of file Image.hpp.

References set().

◆ Image() [8/9]

raylib::Image::Image ( int  width,
int  height,
Color  color = WHITE 
)
inline

Definition at line 55 of file Image.hpp.

References set().

◆ Image() [9/9]

raylib::Image::Image ( ::Font  font,
const std::string &  text,
float  fontSize,
float  spacing,
::Color  tint 
)
inline

Definition at line 58 of file Image.hpp.

References set().

◆ ~Image()

raylib::Image::~Image ( )
inline

Definition at line 135 of file Image.hpp.

References Unload().

Member Function Documentation

◆ AlphaCrop()

Image& raylib::Image::AlphaCrop ( float  threshold)
inline

Crop image depending on alpha value.

Definition at line 231 of file Image.hpp.

◆ AlphaMask()

Image& raylib::Image::AlphaMask ( Image  alphaMask)
inline

Apply alpha mask to image.

Definition at line 223 of file Image.hpp.

◆ AlphaPremultiply()

Image& raylib::Image::AlphaPremultiply ( )
inline

Premultiply alpha channel.

Definition at line 239 of file Image.hpp.

◆ ClearBackground()

Image& raylib::Image::ClearBackground ( ::Color  color = WHITE)
inline

Clear image background with given color.

Definition at line 402 of file Image.hpp.

◆ ColorBrightness()

Image& raylib::Image::ColorBrightness ( int  brightness)
inline

Modify image color: brightness.

Parameters
brightnessBrightness values between -255 and 255

Definition at line 377 of file Image.hpp.

◆ ColorContrast()

Image& raylib::Image::ColorContrast ( float  contrast)
inline

Modify image color: contrast.

Parameters
contrastContrast values between -100 and 100

Definition at line 367 of file Image.hpp.

◆ ColorGrayscale()

Image& raylib::Image::ColorGrayscale ( )
inline

Modify image color: grayscale.

Definition at line 357 of file Image.hpp.

◆ ColorInvert()

Image& raylib::Image::ColorInvert ( )
inline

Modify image color: invert.

Definition at line 349 of file Image.hpp.

◆ ColorReplace()

Image& raylib::Image::ColorReplace ( ::Color  color,
::Color  replace 
)
inline

Modify image color: replace color.

Definition at line 385 of file Image.hpp.

◆ ColorTint()

Image& raylib::Image::ColorTint ( ::Color  color = WHITE)
inline

Modify image color: tint.

Definition at line 341 of file Image.hpp.

◆ Copy()

Image raylib::Image::Copy ( )
inline

Create an image duplicate (useful for transformations)

Definition at line 193 of file Image.hpp.

◆ Crop() [1/2]

Image& raylib::Image::Crop ( ::Rectangle  crop)
inline

Crop an image to area defined by a rectangle.

Definition at line 247 of file Image.hpp.

◆ Crop() [2/2]

Image& raylib::Image::Crop ( int  offsetX,
int  offsetY,
int  newWidth,
int  newHeight 
)
inline

Crop an image to area defined by a rectangle.

Definition at line 255 of file Image.hpp.

◆ Dither()

Image& raylib::Image::Dither ( int  rBpp,
int  gBpp,
int  bBpp,
int  aBpp 
)
inline

Dither image data to 16bpp or lower (Floyd-Steinberg dithering)

Definition at line 301 of file Image.hpp.

◆ Draw()

Image& raylib::Image::Draw ( const ::Image &  src,
::Rectangle  srcRec,
::Rectangle  dstRec,
::Color  tint = WHITE 
)
inline

Definition at line 460 of file Image.hpp.

◆ DrawCircle() [1/2]

Image& raylib::Image::DrawCircle ( ::Vector2  center,
int  radius,
::Color  color 
)
inline

Definition at line 435 of file Image.hpp.

◆ DrawCircle() [2/2]

Image& raylib::Image::DrawCircle ( int  centerX,
int  centerY,
int  radius,
::Color  color 
)
inline

Definition at line 430 of file Image.hpp.

◆ DrawLine() [1/2]

Image& raylib::Image::DrawLine ( ::Vector2  start,
::Vector2  end,
::Color  color 
)
inline

Definition at line 425 of file Image.hpp.

◆ DrawLine() [2/2]

Image& raylib::Image::DrawLine ( int  startPosX,
int  startPosY,
int  endPosX,
int  endPosY,
::Color  color 
)
inline

Definition at line 420 of file Image.hpp.

◆ DrawPixel() [1/2]

Image& raylib::Image::DrawPixel ( ::Vector2  position,
::Color  color 
)
inline

Definition at line 415 of file Image.hpp.

◆ DrawPixel() [2/2]

Image& raylib::Image::DrawPixel ( int  posX,
int  posY,
::Color  color 
)
inline

Draw pixel within an image.

Definition at line 410 of file Image.hpp.

◆ DrawRectangle() [1/3]

Image& raylib::Image::DrawRectangle ( ::Rectangle  rec,
::Color  color = WHITE 
)
inline

Definition at line 450 of file Image.hpp.

◆ DrawRectangle() [2/3]

Image& raylib::Image::DrawRectangle ( int  posX,
int  posY,
int  width,
int  height,
::Color  color = WHITE 
)
inline

Definition at line 440 of file Image.hpp.

◆ DrawRectangle() [3/3]

Image& raylib::Image::DrawRectangle ( Vector2  position,
Vector2  size,
::Color  color = WHITE 
)
inline

Definition at line 445 of file Image.hpp.

◆ DrawRectangleLines()

Image& raylib::Image::DrawRectangleLines ( ::Rectangle  rec,
int  thick,
::Color  color 
)
inline

Definition at line 455 of file Image.hpp.

◆ DrawText() [1/3]

Image& raylib::Image::DrawText ( ::Font  font,
const std::string &  text,
::Vector2  position,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
)
inline

Definition at line 483 of file Image.hpp.

◆ DrawText() [2/3]

Image& raylib::Image::DrawText ( const std::string &  text,
::Vector2  position,
int  fontSize,
::Color  color = WHITE 
)
inline

Definition at line 466 of file Image.hpp.

◆ DrawText() [3/3]

Image& raylib::Image::DrawText ( const std::string &  text,
int  x,
int  y,
int  fontSize,
::Color  color = WHITE 
)
inline

Definition at line 477 of file Image.hpp.

◆ Export()

bool raylib::Image::Export ( const std::string &  fileName)
inline

Export image data to file, returns true on success.

Definition at line 172 of file Image.hpp.

◆ ExportAsCode()

bool raylib::Image::ExportAsCode ( const std::string &  fileName)
inline

Export image as code file defining an array of bytes, returns true on success.

Definition at line 180 of file Image.hpp.

◆ FlipHorizontal()

Image& raylib::Image::FlipHorizontal ( )
inline

Flip image horizontally.

Definition at line 317 of file Image.hpp.

◆ FlipVertical()

Image& raylib::Image::FlipVertical ( )
inline

Flip image vertically.

Definition at line 309 of file Image.hpp.

◆ Format()

Image& raylib::Image::Format ( int  newFormat)
inline

Convert image data to desired format.

Definition at line 215 of file Image.hpp.

◆ FromImage()

Image raylib::Image::FromImage ( ::Rectangle  rec)
inline

Create an image from another image piece.

Definition at line 200 of file Image.hpp.

◆ GenCellular()

static Image raylib::Image::GenCellular ( int  width,
int  height,
int  tileSize 
)
inlinestatic

Generate image: cellular algorithm.

Bigger tileSize means bigger cells

Definition at line 131 of file Image.hpp.

◆ GenChecked()

static Image raylib::Image::GenChecked ( int  width,
int  height,
int  checksX,
int  checksY,
Color  col1,
Color  col2 
)
inlinestatic

Generate image: checked.

Definition at line 109 of file Image.hpp.

◆ GenColor()

static Image raylib::Image::GenColor ( int  width,
int  height,
Color  color 
)
inlinestatic

Generate image: plain color.

Definition at line 80 of file Image.hpp.

◆ GenGradientH()

static Image raylib::Image::GenGradientH ( int  width,
int  height,
Color  left,
Color  right 
)
inlinestatic

Generate image: horizontal gradient.

Definition at line 94 of file Image.hpp.

◆ GenGradientRadial()

static Image raylib::Image::GenGradientRadial ( int  width,
int  height,
float  density,
Color  inner,
Color  outer 
)
inlinestatic

Generate image: radial gradient.

Definition at line 101 of file Image.hpp.

◆ GenGradientV()

static Image raylib::Image::GenGradientV ( int  width,
int  height,
Color  top,
Color  bottom 
)
inlinestatic

Generate image: vertical gradient.

Definition at line 87 of file Image.hpp.

◆ GenPerlinNoise()

static Image raylib::Image::GenPerlinNoise ( int  width,
int  height,
int  offsetX,
int  offsetY,
float  scale 
)
inlinestatic

Generate image: perlin noise.

Definition at line 124 of file Image.hpp.

◆ GenWhiteNoise()

static Image raylib::Image::GenWhiteNoise ( int  width,
int  height,
float  factor 
)
inlinestatic

Generate image: white noise.

Definition at line 117 of file Image.hpp.

◆ GetAlphaBorder()

Rectangle raylib::Image::GetAlphaBorder ( float  threshold) const
inline

Get image alpha border rectangle.

Parameters
thresholdThreshold is defined as a percentatge: 0.0f -> 1.0f

Definition at line 395 of file Image.hpp.

◆ GetData()

void* raylib::Image::GetData ( ) const
inline

Definition at line 184 of file Image.hpp.

◆ GetFormat()

int raylib::Image::GetFormat ( ) const
inline

Definition at line 188 of file Image.hpp.

◆ GetHeight()

int raylib::Image::GetHeight ( ) const
inline

Definition at line 186 of file Image.hpp.

◆ GetMipmaps()

int raylib::Image::GetMipmaps ( ) const
inline

Definition at line 187 of file Image.hpp.

◆ GetScreenData()

static Image raylib::Image::GetScreenData ( )
inlinestatic

Get pixel data from screen buffer and return an Image (screenshot)

Definition at line 73 of file Image.hpp.

References Image().

◆ GetWidth()

int raylib::Image::GetWidth ( ) const
inline

Definition at line 185 of file Image.hpp.

◆ Load()

void raylib::Image::Load ( const std::string &  fileName)
inline

Definition at line 149 of file Image.hpp.

References set().

Referenced by Image().

◆ LoadAnim()

void raylib::Image::LoadAnim ( const std::string &  fileName,
int *  frames 
)
inline

Definition at line 157 of file Image.hpp.

References set().

Referenced by Image().

◆ LoadColors()

inline ::Color* raylib::Image::LoadColors ( )
inline

Load color data from image as a Color array (RGBA - 32bit)

Definition at line 492 of file Image.hpp.

◆ LoadFromMemory()

void raylib::Image::LoadFromMemory ( const std::string &  fileType,
const unsigned char *  fileData,
int  dataSize 
)
inline

Definition at line 161 of file Image.hpp.

References set().

Referenced by Image().

◆ LoadPalette()

inline ::Color* raylib::Image::LoadPalette ( int  maxPaletteSize,
int *  colorsCount 
)
inline

Load colors palette from image as a Color array (RGBA - 32bit)

Definition at line 499 of file Image.hpp.

◆ LoadRaw()

void raylib::Image::LoadRaw ( const std::string &  fileName,
int  width,
int  height,
int  format,
int  headerSize 
)
inline

Definition at line 153 of file Image.hpp.

References set().

Referenced by Image().

◆ LoadTexture()

inline ::Texture2D raylib::Image::LoadTexture ( )
inline

Load texture from image data.

Definition at line 506 of file Image.hpp.

Referenced by operator::Texture2D().

◆ Mipmaps()

Image& raylib::Image::Mipmaps ( )
inline

Generate all mipmap levels for a provided image.

Definition at line 293 of file Image.hpp.

◆ operator::Texture2D()

raylib::Image::operator::Texture2D ( )
inline

Load texture from image data.

Definition at line 513 of file Image.hpp.

References LoadTexture().

◆ operator=() [1/2]

Image& raylib::Image::operator= ( const ::Image &  image)
inline

Definition at line 139 of file Image.hpp.

References set().

◆ operator=() [2/2]

Image& raylib::Image::operator= ( const Image &  image)
inline

Definition at line 144 of file Image.hpp.

References set().

◆ Resize()

Image& raylib::Image::Resize ( int  newWidth,
int  newHeight 
)
inline

Resize and image to new size.

Definition at line 269 of file Image.hpp.

◆ ResizeCanvas()

Image& raylib::Image::ResizeCanvas ( int  newWidth,
int  newHeight,
int  offsetX,
int  offsetY,
Color  color 
)
inline

Resize canvas and fill with color.

Definition at line 285 of file Image.hpp.

◆ ResizeNN()

Image& raylib::Image::ResizeNN ( int  newWidth,
int  newHeight 
)
inline

Resize and image to new size using Nearest-Neighbor scaling algorithm.

Definition at line 277 of file Image.hpp.

◆ RotateCCW()

Image& raylib::Image::RotateCCW ( )
inline

Rotate image counter-clockwise 90deg.

Definition at line 333 of file Image.hpp.

◆ RotateCW()

Image& raylib::Image::RotateCW ( )
inline

Rotate image clockwise 90deg.

Definition at line 325 of file Image.hpp.

◆ set()

void raylib::Image::set ( ::Image  image)
inlineprotected

Definition at line 518 of file Image.hpp.

Referenced by Image(), Load(), LoadAnim(), LoadFromMemory(), LoadRaw(), and operator=().

◆ SetData()

void raylib::Image::SetData ( void *  value)
inline

Definition at line 184 of file Image.hpp.

◆ SetFormat()

void raylib::Image::SetFormat ( int  value)
inline

Definition at line 188 of file Image.hpp.

◆ SetHeight()

void raylib::Image::SetHeight ( int  value)
inline

Definition at line 186 of file Image.hpp.

◆ SetMipmaps()

void raylib::Image::SetMipmaps ( int  value)
inline

Definition at line 187 of file Image.hpp.

◆ SetWidth()

void raylib::Image::SetWidth ( int  value)
inline

Definition at line 185 of file Image.hpp.

◆ Text() [1/2]

static Image raylib::Image::Text ( ::Font  font,
std::string  text,
float  fontSize,
float  spacing,
::Color  tint 
)
inlinestatic

Definition at line 66 of file Image.hpp.

◆ Text() [2/2]

static Image raylib::Image::Text ( std::string  text,
int  fontSize,
Color  color 
)
inlinestatic

Definition at line 62 of file Image.hpp.

◆ ToPOT()

Image& raylib::Image::ToPOT ( Color  fillColor)
inline

Convert image to POT (power-of-two)

Definition at line 207 of file Image.hpp.

◆ Unload()

void raylib::Image::Unload ( )
inline

Definition at line 165 of file Image.hpp.

Referenced by ~Image().