raylib-cpp
C++ object-oriented wrapper library for raylib.
Image.hpp
1#ifndef RAYLIB_CPP_INCLUDE_IMAGE_HPP_
2#define RAYLIB_CPP_INCLUDE_IMAGE_HPP_
3
4#include <string>
5
6#include "./raylib.hpp"
7#include "./raylib-cpp-utils.hpp"
8#include "./RaylibException.hpp"
9
10namespace raylib {
16class Image : public ::Image {
17 public:
18 Image(void* data = nullptr,
19 int width = 0,
20 int height = 0,
21 int mipmaps = 0,
22 int format = 0) : ::Image{data, width, height, mipmaps, format} {
23 // Nothing.
24 }
25
26 Image(const ::Image& image) {
27 set(image);
28 }
29
37 Image(const std::string& fileName) {
38 if (!Load(fileName)) {
39 throw RaylibException(TextFormat("Failed to load Image from file: %s", fileName.c_str()));
40 }
41 }
42
50 Image(const std::string& fileName, int width, int height, int format, int headerSize) {
51 if (!Load(fileName, width, height, format, headerSize)) {
52 throw RaylibException(TextFormat("Failed to load Image from file: %s", fileName.c_str()));
53 }
54 }
55
63 Image(const std::string& fileName, int* frames) {
64 if (!Load(fileName, frames)) {
65 throw RaylibException(TextFormat("Failed to load Image from animation: %s", fileName.c_str()));
66 }
67 }
68
74 Image(const std::string& fileType, const unsigned char* fileData, int dataSize) {
75 if (!Load(fileType, fileData, dataSize)) {
76 throw RaylibException("Failed to load Image from memory");
77 }
78 }
79
85 Image(const ::Texture2D& texture) {
86 if (!Load(texture)) {
87 throw RaylibException("Failed to load Image from Texture");
88 }
89 }
90
91 Image(int width, int height, ::Color color = {255, 255, 255, 255}) {
92 set(::GenImageColor(width, height, color));
93 }
94
95 Image(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) {
96 set(::ImageText(text.c_str(), fontSize, color));
97 }
98
99 Image(const ::Font& font, const std::string& text, float fontSize, float spacing,
100 ::Color tint = {255, 255, 255, 255}) {
101 set(::ImageTextEx(font, text.c_str(), fontSize, spacing, tint));
102 }
103
104 Image(const Image& other) {
105 set(other.Copy());
106 }
107
108 Image(Image&& other) {
109 set(other);
110
111 other.data = nullptr;
112 other.width = 0;
113 other.height = 0;
114 other.mipmaps = 0;
115 other.format = 0;
116 }
117
118 static ::Image Text(const std::string& text, int fontSize,
119 ::Color color = {255, 255, 255, 255}) {
120 return ::ImageText(text.c_str(), fontSize, color);
121 }
122
123 static ::Image Text(const ::Font& font, const std::string& text, float fontSize, float spacing,
124 ::Color tint = {255, 255, 255, 255}) {
125 return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
126 }
127
131 static ::Image LoadFromScreen() {
132 return ::LoadImageFromScreen();
133 }
134
138 static ::Image Color(int width, int height, ::Color color = {255, 255, 255, 255}) {
139 return ::GenImageColor(width, height, color);
140 }
141
145 static ::Image GradientV(int width, int height, ::Color top, ::Color bottom) {
146 return ::GenImageGradientV(width, height, top, bottom);
147 }
148
152 static ::Image GradientH(int width, int height, ::Color left, ::Color right) {
153 return ::GenImageGradientH(width, height, left, right);
154 }
155
159 static ::Image GradientRadial(int width, int height, float density,
160 ::Color inner, ::Color outer) {
161 return ::GenImageGradientRadial(width, height, density, inner, outer);
162 }
163
167 static ::Image Checked(int width, int height, int checksX, int checksY,
168 ::Color col1 = {255, 255, 255, 255}, ::Color col2 = {0, 0, 0, 255}) {
169 return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
170 }
171
175 static ::Image WhiteNoise(int width, int height, float factor) {
176 return ::GenImageWhiteNoise(width, height, factor);
177 }
178
182 static ::Image Cellular(int width, int height, int tileSize) {
183 return ::GenImageCellular(width, height, tileSize);
184 }
185
187 Unload();
188 }
189
190 Image& operator=(const ::Image& image) {
191 set(image);
192 return *this;
193 }
194
195 Image& operator=(const Image& other) {
196 if (this == &other) {
197 return *this;
198 }
199
200 Unload();
201 set(other.Copy());
202
203 return *this;
204 }
205
206 Image& operator=(Image&& other) noexcept {
207 if (this == &other) {
208 return *this;
209 }
210
211 Unload();
212 set(other);
213
214 other.data = nullptr;
215 other.width = 0;
216 other.height = 0;
217 other.mipmaps = 0;
218 other.format = 0;
219
220 return *this;
221 }
222
230 bool Load(const std::string& fileName) {
231 set(::LoadImage(fileName.c_str()));
232 return IsReady();
233 }
234
242 bool Load(const std::string& fileName, int width, int height, int format, int headerSize) {
243 set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
244 return IsReady();
245 }
246
254 bool Load(const std::string& fileName, int* frames) {
255 set(::LoadImageAnim(fileName.c_str(), frames));
256 return IsReady();
257 }
258
266 bool Load(
267 const std::string& fileType,
268 const unsigned char *fileData,
269 int dataSize) {
270 set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize));
271 return IsReady();
272 }
273
281 bool Load(const ::Texture2D& texture) {
282 set(::LoadImageFromTexture(texture));
283 return IsReady();
284 }
285
289 inline void Unload() {
290 if (data != nullptr) {
291 ::UnloadImage(*this);
292 data = nullptr;
293 }
294 }
295
299 inline bool Export(const std::string& fileName) const {
300 // TODO(RobLoach): Switch to an invalid loading exception on false.
301 return ::ExportImage(*this, fileName.c_str());
302 }
303
307 inline bool ExportAsCode(const std::string& fileName) const {
308 return ::ExportImageAsCode(*this, fileName.c_str());
309 }
310
311 GETTERSETTER(void*, Data, data)
312 GETTERSETTER(int, Width, width)
313 GETTERSETTER(int, Height, height)
314 GETTERSETTER(int, Mipmaps, mipmaps)
315 GETTERSETTER(int, Format, format)
316
320 inline ::Vector2 GetSize() const {
321 return {static_cast<float>(width), static_cast<float>(height)};
322 }
323
327 inline ::Image Copy() const {
328 return ::ImageCopy(*this);
329 }
330
334 inline ::Image FromImage(::Rectangle rec) const {
335 return ::ImageFromImage(*this, rec);
336 }
337
341 inline Image& ToPOT(::Color fillColor) {
342 ::ImageToPOT(this, fillColor);
343 return *this;
344 }
345
349 inline Image& Format(int newFormat) {
350 ::ImageFormat(this, newFormat);
351 return *this;
352 }
353
357 inline Image& AlphaCrop(float threshold) {
358 ::ImageAlphaCrop(this, threshold);
359 return *this;
360 }
361
365 inline Image& AlphaClear(::Color color, float threshold) {
366 ::ImageAlphaClear(this, color, threshold);
367 return *this;
368 }
369
373 inline Image& AlphaMask(const ::Image& alphaMask) {
374 ::ImageAlphaMask(this, alphaMask);
375 return *this;
376 }
377
382 ::ImageAlphaPremultiply(this);
383 return *this;
384 }
385
389 inline Image& Crop(::Rectangle crop) {
390 ::ImageCrop(this, crop);
391 return *this;
392 }
393
397 inline Image& Crop(int newWidth, int newHeight) {
398 return Crop(0, 0, newWidth, newHeight);
399 }
400
404 inline Image& Crop(::Vector2 size) {
405 return Crop(0, 0, static_cast<int>(size.x), static_cast<int>(size.y));
406 }
407
411 inline Image& Crop(int offsetX, int offsetY, int newWidth, int newHeight) {
412 ::Rectangle rect{
413 static_cast<float>(offsetX),
414 static_cast<float>(offsetY),
415 static_cast<float>(newWidth),
416 static_cast<float>(newHeight)
417 };
418 ::ImageCrop(this, rect);
419 return *this;
420 }
421
425 inline Image& Resize(int newWidth, int newHeight) {
426 ::ImageResize(this, newWidth, newHeight);
427 return *this;
428 }
429
433 inline Image& ResizeNN(int newWidth, int newHeight) {
434 ::ImageResizeNN(this, newWidth, newHeight);
435 return *this;
436 }
437
441 inline Image& ResizeCanvas(int newWidth, int newHeight, int offsetX = 0, int offsetY = 0,
442 ::Color color = {255, 255, 255, 255}) {
443 ::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
444 return *this;
445 }
446
450 inline Image& Mipmaps() {
451 ::ImageMipmaps(this);
452 return *this;
453 }
454
458 inline Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
459 ::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
460 return *this;
461 }
462
466 inline Image& FlipVertical() {
467 ::ImageFlipVertical(this);
468 return *this;
469 }
470
475 ::ImageFlipHorizontal(this);
476 return *this;
477 }
478
482 inline Image& RotateCW() {
483 ::ImageRotateCW(this);
484 return *this;
485 }
486
490 inline Image& RotateCCW() {
491 ::ImageRotateCCW(this);
492 return *this;
493 }
494
498 inline Image& ColorTint(::Color color = {255, 255, 255, 255}) {
499 ::ImageColorTint(this, color);
500 return *this;
501 }
502
506 inline Image& ColorInvert() {
507 ::ImageColorInvert(this);
508 return *this;
509 }
510
515 ::ImageColorGrayscale(this);
516 return *this;
517 }
518
524 inline Image& ColorContrast(float contrast) {
525 ::ImageColorContrast(this, contrast);
526 return *this;
527 }
528
534 inline Image& ColorBrightness(int brightness) {
535 ::ImageColorBrightness(this, brightness);
536 return *this;
537 }
538
542 inline Image& ColorReplace(::Color color, ::Color replace) {
543 ::ImageColorReplace(this, color, replace);
544 return *this;
545 }
546
552 inline Rectangle GetAlphaBorder(float threshold) const {
553 return ::GetImageAlphaBorder(*this, threshold);
554 }
555
559 inline Image& ClearBackground(::Color color = {0, 0, 0, 255}) {
560 ::ImageClearBackground(this, color);
561 return *this;
562 }
563
567 inline Image& DrawPixel(int posX, int posY, ::Color color = {255, 255, 255, 255}) {
568 ::ImageDrawPixel(this, posX, posY, color);
569 return *this;
570 }
571
572 inline Image& DrawPixel(::Vector2 position, ::Color color = {255, 255, 255, 255}) {
573 ::ImageDrawPixelV(this, position, color);
574 return *this;
575 }
576
577 inline Image& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY,
578 ::Color color = {255, 255, 255, 255}) {
579 ::ImageDrawLine(this, startPosX, startPosY, endPosX, endPosY, color);
580 return *this;
581 }
582
583 inline Image& DrawLine(::Vector2 start, ::Vector2 end, ::Color color = {255, 255, 255, 255}) {
584 ::ImageDrawLineV(this, start, end, color);
585 return *this;
586 }
587
588 inline Image& DrawCircle(int centerX, int centerY, int radius,
589 ::Color color = {255, 255, 255, 255}) {
590 ::ImageDrawCircle(this, centerX, centerY, radius, color);
591 return *this;
592 }
593
594 inline Image& DrawCircle(::Vector2 center, int radius,
595 ::Color color = {255, 255, 255, 255}) {
596 ::ImageDrawCircleV(this, center, radius, color);
597 return *this;
598 }
599
600 inline Image& DrawRectangle(int posX, int posY, int width, int height,
601 ::Color color = {255, 255, 255, 255}) {
602 ::ImageDrawRectangle(this, posX, posY, width, height, color);
603 return *this;
604 }
605
606 inline Image& DrawRectangle(Vector2 position, Vector2 size,
607 ::Color color = {255, 255, 255, 255}) {
608 ::ImageDrawRectangleV(this, position, size, color);
609 return *this;
610 }
611
612 inline Image& DrawRectangle(::Rectangle rec, ::Color color = {255, 255, 255, 255}) {
613 ::ImageDrawRectangleRec(this, rec, color);
614 return *this;
615 }
616
617 inline Image& DrawRectangleLines(::Rectangle rec, int thick = 1,
618 ::Color color = {255, 255, 255, 255}) {
619 ::ImageDrawRectangleLines(this, rec, thick, color);
620 return *this;
621 }
622
623 inline Image& Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec,
624 ::Color tint = {255, 255, 255, 255}) {
625 ::ImageDraw(this, src, srcRec, dstRec, tint);
626 return *this;
627 }
628
629 inline Image& DrawText(const std::string& text, ::Vector2 position, int fontSize,
630 ::Color color = {255, 255, 255, 255}) {
631 ::ImageDrawText(this,
632 text.c_str(),
633 static_cast<int>(position.x),
634 static_cast<int>(position.y),
635 fontSize,
636 color);
637 return *this;
638 }
639
640 inline Image& DrawText(const std::string& text, int x, int y, int fontSize,
641 ::Color color = {255, 255, 255, 255}) {
642 ::ImageDrawText(this, text.c_str(), x, y, fontSize, color);
643 return *this;
644 }
645
646 inline Image& DrawText(const ::Font& font, const std::string& text, ::Vector2 position,
647 float fontSize, float spacing, ::Color tint = {255, 255, 255, 255}) {
648 ::ImageDrawTextEx(this, font, text.c_str(), position, fontSize, spacing, tint);
649 return *this;
650 }
651
655 inline ::Color* LoadColors() const {
656 return ::LoadImageColors(*this);
657 }
658
662 inline ::Color* LoadPalette(int maxPaletteSize, int *colorsCount) const {
663 return ::LoadImagePalette(*this, maxPaletteSize, colorsCount);
664 }
665
669 inline void UnloadColors(::Color* colors) const {
670 ::UnloadImageColors(colors);
671 }
672
676 inline void UnloadPalette(::Color* colors) const {
677 ::UnloadImagePalette(colors);
678 }
679
683 inline ::Texture2D LoadTexture() const {
684 return ::LoadTextureFromImage(*this);
685 }
686
692 inline operator ::Texture2D() {
693 return LoadTexture();
694 }
695
699 static int GetPixelDataSize(int width, int height, int format = PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) {
700 return ::GetPixelDataSize(width, height, format);
701 }
702
708 int GetPixelDataSize() const {
709 return ::GetPixelDataSize(width, height, format);
710 }
711
717 inline bool IsReady() const {
718 return data != nullptr;
719 }
720
721 private:
722 inline void set(const ::Image& image) {
723 data = image.data;
724 width = image.width;
725 height = image.height;
726 mipmaps = image.mipmaps;
727 format = image.format;
728 }
729};
730} // namespace raylib
731
732#endif // RAYLIB_CPP_INCLUDE_IMAGE_HPP_
Image type, bpp always RGBA (32bit)
Definition: Image.hpp:16
Image & Draw(const ::Image &src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint={255, 255, 255, 255})
Definition: Image.hpp:623
Image & ColorContrast(float contrast)
Modify image color: contrast.
Definition: Image.hpp:524
Image & Dither(int rBpp, int gBpp, int bBpp, int aBpp)
Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
Definition: Image.hpp:458
Image & DrawRectangle(Vector2 position, Vector2 size, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:606
Image(const std::string &text, int fontSize, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:95
::Image WhiteNoise(int width, int height, float factor)
Generate image: white noise.
Definition: Image.hpp:175
Image & DrawText(const std::string &text, int x, int y, int fontSize, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:640
::Image GradientH(int width, int height, ::Color left, ::Color right)
Generate image: horizontal gradient.
Definition: Image.hpp:152
Image & ColorTint(::Color color={255, 255, 255, 255})
Modify image color: tint.
Definition: Image.hpp:498
inline ::Color * LoadPalette(int maxPaletteSize, int *colorsCount) const
Load colors palette from image as a Color array (RGBA - 32bit)
Definition: Image.hpp:662
Image & ResizeNN(int newWidth, int newHeight)
Resize and image to new size using Nearest-Neighbor scaling algorithm.
Definition: Image.hpp:433
Image & ResizeCanvas(int newWidth, int newHeight, int offsetX=0, int offsetY=0, ::Color color={255, 255, 255, 255})
Resize canvas and fill with color.
Definition: Image.hpp:441
Image & operator=(const Image &other)
Definition: Image.hpp:195
Image & DrawCircle(::Vector2 center, int radius, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:594
::Image Checked(int width, int height, int checksX, int checksY, ::Color col1={255, 255, 255, 255}, ::Color col2={0, 0, 0, 255})
Generate image: checked.
Definition: Image.hpp:167
::Image Text(const ::Font &font, const std::string &text, float fontSize, float spacing, ::Color tint={255, 255, 255, 255})
Definition: Image.hpp:123
::Image Cellular(int width, int height, int tileSize)
Generate image: cellular algorithm.
Definition: Image.hpp:182
Image(const std::string &fileType, const unsigned char *fileData, int dataSize)
Load an image from the given file.
Definition: Image.hpp:74
Image(void *data=nullptr, int width=0, int height=0, int mipmaps=0, int format=0)
Definition: Image.hpp:18
Image & DrawRectangle(int posX, int posY, int width, int height, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:600
Image(const ::Texture2D &texture)
Load an image from the given file.
Definition: Image.hpp:85
Rectangle GetAlphaBorder(float threshold) const
Get image alpha border rectangle.
Definition: Image.hpp:552
inline ::Image Copy() const
Create an image duplicate (useful for transformations)
Definition: Image.hpp:327
bool Load(const std::string &fileType, const unsigned char *fileData, int dataSize)
Load image from memory buffer, fileType refers to extension: i.e.
Definition: Image.hpp:266
Image(int width, int height, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:91
Image(const std::string &fileName, int width, int height, int format, int headerSize)
Load a raw image from the given file, with the provided width, height, and formats.
Definition: Image.hpp:50
Image & DrawRectangle(::Rectangle rec, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:612
int GetPixelDataSize() const
Returns the pixel data size based on the current image.
Definition: Image.hpp:708
bool Export(const std::string &fileName) const
Export image data to file, returns true on success.
Definition: Image.hpp:299
::Image GradientV(int width, int height, ::Color top, ::Color bottom)
Generate image: vertical gradient.
Definition: Image.hpp:145
bool IsReady() const
Retrieve whether or not the Image has been loaded.
Definition: Image.hpp:717
Image & DrawPixel(int posX, int posY, ::Color color={255, 255, 255, 255})
Draw pixel within an image.
Definition: Image.hpp:567
Image & ColorGrayscale()
Modify image color: grayscale.
Definition: Image.hpp:514
inline ::Image FromImage(::Rectangle rec) const
Create an image from another image piece.
Definition: Image.hpp:334
bool Load(const std::string &fileName, int width, int height, int format, int headerSize)
Load image from RAW file data.
Definition: Image.hpp:242
Image & ColorBrightness(int brightness)
Modify image color: brightness.
Definition: Image.hpp:534
Image & RotateCW()
Rotate image clockwise 90deg.
Definition: Image.hpp:482
Image & FlipHorizontal()
Flip image horizontally.
Definition: Image.hpp:474
Image & AlphaPremultiply()
Premultiply alpha channel.
Definition: Image.hpp:381
Image & ToPOT(::Color fillColor)
Convert image to POT (power-of-two)
Definition: Image.hpp:341
Image(const std::string &fileName, int *frames)
Load an animation image from the given file.
Definition: Image.hpp:63
Image & ClearBackground(::Color color={0, 0, 0, 255})
Clear image background with given color.
Definition: Image.hpp:559
Image & operator=(Image &&other) noexcept
Definition: Image.hpp:206
Image(const Image &other)
Definition: Image.hpp:104
Image & Crop(int offsetX, int offsetY, int newWidth, int newHeight)
Crop an image to area defined by a rectangle.
Definition: Image.hpp:411
Image(const std::string &fileName)
Load an image from the given file.
Definition: Image.hpp:37
bool Load(const ::Texture2D &texture)
Load an image from the given file.
Definition: Image.hpp:281
::Image Color(int width, int height, ::Color color={255, 255, 255, 255})
Generate image: plain color.
Definition: Image.hpp:138
Image & FlipVertical()
Flip image vertically.
Definition: Image.hpp:466
::Image Text(const std::string &text, int fontSize, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:118
Image & RotateCCW()
Rotate image counter-clockwise 90deg.
Definition: Image.hpp:490
Image & Format(int newFormat)
Convert image data to desired format.
Definition: Image.hpp:349
Image & AlphaCrop(float threshold)
Crop image depending on alpha value.
Definition: Image.hpp:357
Image & DrawText(const std::string &text, ::Vector2 position, int fontSize, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:629
inline ::Texture2D LoadTexture() const
Load texture from image data.
Definition: Image.hpp:683
Image & DrawRectangleLines(::Rectangle rec, int thick=1, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:617
static int GetPixelDataSize(int width, int height, int format=PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)
Get pixel data size in bytes for certain format.
Definition: Image.hpp:699
Image & operator=(const ::Image &image)
Definition: Image.hpp:190
Image & DrawText(const ::Font &font, const std::string &text, ::Vector2 position, float fontSize, float spacing, ::Color tint={255, 255, 255, 255})
Definition: Image.hpp:646
::Image GradientRadial(int width, int height, float density, ::Color inner, ::Color outer)
Generate image: radial gradient.
Definition: Image.hpp:159
Image & Mipmaps()
Generate all mipmap levels for a provided image.
Definition: Image.hpp:450
Image & AlphaMask(const ::Image &alphaMask)
Apply alpha mask to image.
Definition: Image.hpp:373
::Image LoadFromScreen()
Get pixel data from screen buffer and return an Image (screenshot)
Definition: Image.hpp:131
Image(Image &&other)
Definition: Image.hpp:108
bool Load(const std::string &fileName)
Load image from file into CPU memory (RAM)
Definition: Image.hpp:230
Image & ColorInvert()
Modify image color: invert.
Definition: Image.hpp:506
inline ::Vector2 GetSize() const
Retrieve the width and height of the image.
Definition: Image.hpp:320
void Unload()
Unload image from CPU memory (RAM)
Definition: Image.hpp:289
Image & DrawLine(::Vector2 start, ::Vector2 end, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:583
Image & Crop(int newWidth, int newHeight)
Crop an image to a new given width and height.
Definition: Image.hpp:397
inline ::Color * LoadColors() const
Load color data from image as a Color array (RGBA - 32bit)
Definition: Image.hpp:655
void UnloadColors(::Color *colors) const
Unload color data loaded with LoadImageColors()
Definition: Image.hpp:669
bool Load(const std::string &fileName, int *frames)
Load image sequence from file (frames appended to image.data).
Definition: Image.hpp:254
Image & DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:577
Image(const ::Font &font, const std::string &text, float fontSize, float spacing, ::Color tint={255, 255, 255, 255})
Definition: Image.hpp:99
Image & ColorReplace(::Color color, ::Color replace)
Modify image color: replace color.
Definition: Image.hpp:542
Image & AlphaClear(::Color color, float threshold)
Clear alpha channel to desired color.
Definition: Image.hpp:365
Image & Crop(::Rectangle crop)
Crop an image to area defined by a rectangle.
Definition: Image.hpp:389
bool ExportAsCode(const std::string &fileName) const
Export image as code file defining an array of bytes, returns true on success.
Definition: Image.hpp:307
void UnloadPalette(::Color *colors) const
Unload colors palette loaded with LoadImagePalette()
Definition: Image.hpp:676
Image(const ::Image &image)
Definition: Image.hpp:26
Image & Resize(int newWidth, int newHeight)
Resize and image to new size.
Definition: Image.hpp:425
Image & Crop(::Vector2 size)
Crop an image to a new given width and height based on a vector.
Definition: Image.hpp:404
Image & DrawPixel(::Vector2 position, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:572
Image & DrawCircle(int centerX, int centerY, int radius, ::Color color={255, 255, 255, 255})
Definition: Image.hpp:588
Exception used for most raylib-related exceptions.
Rectangle type.
Definition: Rectangle.hpp:12
Vector2 type.
Definition: Vector2.hpp:16
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:8
static inline ::Image LoadImage(const std::string &fileName)
Load an image.
Definition: Functions.hpp:210
static inline ::Image LoadImageFromMemory(const std::string &fileType, const unsigned char *fileData, int dataSize)
Load image from memory buffer, fileType refers to extension like "png".
Definition: Functions.hpp:233
static inline ::Image LoadImageAnim(const std::string &fileName, int *frames)
Load animated image data.
Definition: Functions.hpp:226
static inline ::Image LoadImageRaw(const std::string &fileName, int width, int height, int format, int headerSize)
Load an image from RAW file data.
Definition: Functions.hpp:217