raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Image.hpp
1#ifndef RAYLIB_CPP_INCLUDE_IMAGE_HPP_
2#define RAYLIB_CPP_INCLUDE_IMAGE_HPP_
3
4#include <span>
5#include <string>
6#include <string_view>
7
8#include "./raylib.hpp"
9#include "./raylib-cpp-utils.hpp"
10#include "./RaylibException.hpp"
11#include "./Color.hpp"
12
13namespace raylib {
19class Image : public ::Image {
20 public:
21 Image(void* data = nullptr,
22 int width = 0,
23 int height = 0,
24 int mipmaps = 1,
25 int format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) : ::Image{data, width, height, mipmaps, format} {
26 // Nothing.
27 }
28
29 Image(const ::Image& image) {
30 set(image);
31 }
32
40 Image(const std::string_view fileName) {
41 Load(fileName);
42 }
43
51 Image(const std::string_view fileName, int width, int height, int format, int headerSize = 0) {
52 Load(fileName, width, height, format, headerSize);
53 }
54
62 Image(const std::string_view fileName, int* frames) {
63 Load(fileName, frames);
64 }
65
73 Image(const std::string_view fileName, std::span<int> frames) {
74 Load(fileName, frames.data());
75 }
76
82 Image(const std::string_view fileType, const unsigned char* fileData, int dataSize) {
83 Load(fileType, fileData, dataSize);
84 }
85
91 Image(const ::Texture2D& texture) {
92 Load(texture);
93 }
94
95 Image(int width, int height, ::Color color = {255, 255, 255, 255}) {
96 set(::GenImageColor(width, height, color));
97 }
98
99 Image(const std::string_view text, int fontSize, ::Color color = {255, 255, 255, 255}) {
100 set(::ImageText(text.data(), fontSize, color));
101 }
102
103 Image(const ::Font& font, const std::string_view text, float fontSize, float spacing,
104 ::Color tint = {255, 255, 255, 255}) {
105 set(::ImageTextEx(font, text.data(), fontSize, spacing, tint));
106 }
107
108 Image(const Image& other) {
109 set(other.Copy());
110 }
111
112 Image(Image&& other) {
113 set(other);
114
115 other.data = nullptr;
116 other.width = 0;
117 other.height = 0;
118 other.mipmaps = 0;
119 other.format = 0;
120 }
121
122 static ::Image Text(const std::string_view text, int fontSize,
123 ::Color color = {255, 255, 255, 255}) {
124 return ::ImageText(text.data(), fontSize, color);
125 }
126
127 static ::Image Text(const ::Font& font, const std::string_view text, float fontSize, float spacing,
128 ::Color tint = {255, 255, 255, 255}) {
129 return ::ImageTextEx(font, text.data(), fontSize, spacing, tint);
130 }
131
135 static ::Image LoadFromScreen() {
136 return ::LoadImageFromScreen();
137 }
138
142 static ::Image Color(int width, int height, ::Color color = {255, 255, 255, 255}) {
143 return ::GenImageColor(width, height, color);
144 }
145
149 static ::Image GradientLinear(int width, int height, int direction, ::Color start, ::Color end) {
150 return ::GenImageGradientLinear(width, height, direction, start, end);
151 }
152
156 static ::Image GradientRadial(int width, int height, float density,
157 ::Color inner, ::Color outer) {
158 return ::GenImageGradientRadial(width, height, density, inner, outer);
159 }
160
164 static ::Image Checked(int width, int height, int checksX, int checksY,
165 ::Color col1 = {255, 255, 255, 255}, ::Color col2 = {0, 0, 0, 255}) {
166 return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
167 }
168
172 static ::Image WhiteNoise(int width, int height, float factor) {
173 return ::GenImageWhiteNoise(width, height, factor);
174 }
175
179 static ::Image Cellular(int width, int height, int tileSize) {
180 return ::GenImageCellular(width, height, tileSize);
181 }
182
183 ~Image() {
184 Unload();
185 }
186
187 Image& operator=(const ::Image& image) {
188 set(image);
189 return *this;
190 }
191
192 Image& operator=(const Image& other) {
193 if (this == &other) {
194 return *this;
195 }
196
197 Unload();
198 set(other.Copy());
199
200 return *this;
201 }
202
203 Image& operator=(Image&& other) noexcept {
204 if (this == &other) {
205 return *this;
206 }
207
208 Unload();
209 set(other);
210
211 other.data = nullptr;
212 other.width = 0;
213 other.height = 0;
214 other.mipmaps = 0;
215 other.format = 0;
216
217 return *this;
218 }
219
227 void Load(const std::string_view fileName) {
228 set(::LoadImage(fileName.data()));
229 if (!IsReady()) {
230 throw RaylibException("Failed to load Image from file: " + std::string(fileName));
231 }
232 }
233
241 void Load(const std::string_view fileName, int width, int height, int format, int headerSize) {
242 set(::LoadImageRaw(fileName.data(), width, height, format, headerSize));
243 if (!IsReady()) {
244 throw RaylibException("Failed to load Image from file: " + std::string(fileName));
245 }
246 }
247
255 void Load(const std::string_view fileName, int* frames) {
256 set(::LoadImageAnim(fileName.data(), frames));
257 if (!IsReady()) {
258 throw RaylibException("Failed to load Image from file: " + std::string(fileName));
259 }
260 }
261
269 void Load(const std::string_view fileName, std::span<int> frames) {
270 set(::LoadImageAnim(fileName.data(), frames.data()));
271 if (!IsReady()) {
272 throw RaylibException("Failed to load Image from file: " + std::string(fileName));
273 }
274 }
275
283 void Load(
284 const std::string_view fileType,
285 const unsigned char *fileData,
286 int dataSize) {
287 set(::LoadImageFromMemory(fileType.data(), fileData, dataSize));
288 if (!IsReady()) {
289 throw RaylibException("Failed to load Image data with file type: " + std::string(fileType));
290 }
291 }
292
300 void Load(
301 const std::string_view fileType,
302 const std::span<unsigned char> fileData) {
303 set(::LoadImageFromMemory(fileType.data(), fileData.data(), static_cast<int>(fileData.size())));
304 if (!IsReady()) {
305 throw RaylibException("Failed to load Image data with file type: " + std::string(fileType));
306 }
307 }
308
316 void Load(const ::Texture2D& texture) {
317 set(::LoadImageFromTexture(texture));
318 if (!IsReady()) {
319 throw RaylibException("Failed to load Image from texture.");
320 }
321 }
322
326 void Unload() {
327 if (data != nullptr) {
328 ::UnloadImage(*this);
329 data = nullptr;
330 }
331 }
332
338 void Export(const std::string_view fileName) const {
339 if (!::ExportImage(*this, fileName.data())) {
340 throw RaylibException(TextFormat("Failed to export Image to file: %s", fileName.data()));
341 }
342 }
343
347 unsigned char* ExportToMemory(const char *fileType, int *fileSize) {
348 return ::ExportImageToMemory(*this, fileType, fileSize);
349 }
350
351 unsigned char* ExportToMemory(const std::string_view fileType, std::span<int> fileSize) {
352 return ::ExportImageToMemory(*this, fileType.data(), fileSize.data());
353 }
354
360 void ExportAsCode(const std::string_view fileName) const {
361 if (!::ExportImageAsCode(*this, fileName.data())) {
362 throw RaylibException(TextFormat("Failed to export Image code to file: %s", fileName.data()));
363 }
364 }
365
366 GETTER(void*, Data, data)
367 GETTER(int, Width, width)
368 GETTER(int, Height, height)
369 GETTER(int, Mipmaps, mipmaps)
370 GETTER(int, Format, format)
371
377 void SetWidth(int width, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
378 ResizeCanvas(width, height, offsetX, offsetY, fill);
379 }
380
386 void SetHeight(int height, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
387 ResizeCanvas(width, height, offsetX, offsetY, fill);
388 }
389
393 ::Vector2 GetSize() const {
394 return {static_cast<float>(width), static_cast<float>(height)};
395 }
396
400 ::Image Copy() const {
401 return ::ImageCopy(*this);
402 }
403
407 ::Image FromImage(::Rectangle rec) const {
408 return ::ImageFromImage(*this, rec);
409 }
410
414 Image& Format(int newFormat) {
415 ::ImageFormat(this, newFormat);
416 return *this;
417 }
418
422 Image& ToPOT(::Color fillColor) {
423 ::ImageToPOT(this, fillColor);
424 return *this;
425 }
426
430 Image& Crop(::Rectangle crop) {
431 ::ImageCrop(this, crop);
432 return *this;
433 }
434
438 Image& AlphaCrop(float threshold) {
439 ::ImageAlphaCrop(this, threshold);
440 return *this;
441 }
442
446 Image& AlphaClear(::Color color, float threshold) {
447 ::ImageAlphaClear(this, color, threshold);
448 return *this;
449 }
450
454 Image& AlphaMask(const ::Image& alphaMask) {
455 ::ImageAlphaMask(this, alphaMask);
456 return *this;
457 }
458
463 ::ImageAlphaPremultiply(this);
464 return *this;
465 }
466
470 Image& Crop(int newWidth, int newHeight) {
471 return Crop(0, 0, newWidth, newHeight);
472 }
473
477 Image& Crop(::Vector2 size) {
478 return Crop(0, 0, static_cast<int>(size.x), static_cast<int>(size.y));
479 }
480
484 Image& Crop(int offsetX, int offsetY, int newWidth, int newHeight) {
485 ::Rectangle rect{
486 static_cast<float>(offsetX),
487 static_cast<float>(offsetY),
488 static_cast<float>(newWidth),
489 static_cast<float>(newHeight)
490 };
491 ::ImageCrop(this, rect);
492 return *this;
493 }
494
498 Image& Resize(int newWidth, int newHeight) {
499 ::ImageResize(this, newWidth, newHeight);
500 return *this;
501 }
502
506 Image& ResizeNN(int newWidth, int newHeight) {
507 ::ImageResizeNN(this, newWidth, newHeight);
508 return *this;
509 }
510
514 Image& ResizeCanvas(int newWidth, int newHeight, int offsetX = 0, int offsetY = 0,
515 ::Color color = {255, 255, 255, 255}) {
516 ::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
517 return *this;
518 }
519
524 ::ImageMipmaps(this);
525 return *this;
526 }
527
531 Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
532 ::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
533 return *this;
534 }
535
540 ::ImageFlipVertical(this);
541 return *this;
542 }
543
548 ::ImageFlipHorizontal(this);
549 return *this;
550 }
551
557 Image& Rotate(Degree degrees) {
558 ::ImageRotate(this, static_cast<int>(degrees));
559 return *this;
560 }
561
566 ::ImageRotateCW(this);
567 return *this;
568 }
569
574 ::ImageRotateCCW(this);
575 return *this;
576 }
577
581 Image& ColorTint(::Color color = {255, 255, 255, 255}) {
582 ::ImageColorTint(this, color);
583 return *this;
584 }
585
590 ::ImageColorInvert(this);
591 return *this;
592 }
593
598 ::ImageColorGrayscale(this);
599 return *this;
600 }
601
607 Image& ColorContrast(float contrast) {
608 ::ImageColorContrast(this, contrast);
609 return *this;
610 }
611
617 Image& ColorBrightness(int brightness) {
618 ::ImageColorBrightness(this, brightness);
619 return *this;
620 }
621
625 Image& ColorReplace(::Color color, ::Color replace) {
626 ::ImageColorReplace(this, color, replace);
627 return *this;
628 }
629
635 Rectangle GetAlphaBorder(float threshold) const {
636 return ::GetImageAlphaBorder(*this, threshold);
637 }
638
642 raylib::Color GetColor(int x = 0, int y = 0) const {
643 return ::GetImageColor(*this, x, y);
644 }
645
649 raylib::Color GetColor(::Vector2 position) const {
650 return ::GetImageColor(*this, static_cast<int>(position.x), static_cast<int>(position.y));
651 }
652
656 Image& ClearBackground(::Color color = {0, 0, 0, 255}) {
657 ::ImageClearBackground(this, color);
658 return *this;
659 }
660
664 void DrawPixel(int posX, int posY, ::Color color = {255, 255, 255, 255}) {
665 ::ImageDrawPixel(this, posX, posY, color);
666 }
667
668 void DrawPixel(::Vector2 position, ::Color color = {255, 255, 255, 255}) {
669 ::ImageDrawPixelV(this, position, color);
670 }
671
672 void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY,
673 ::Color color = {255, 255, 255, 255}) {
674 ::ImageDrawLine(this, startPosX, startPosY, endPosX, endPosY, color);
675 }
676
677 void DrawLine(::Vector2 start, ::Vector2 end, ::Color color = {255, 255, 255, 255}) {
678 ::ImageDrawLineV(this, start, end, color);
679 }
680
681 void DrawCircle(int centerX, int centerY, int radius,
682 ::Color color = {255, 255, 255, 255}) {
683 ::ImageDrawCircle(this, centerX, centerY, radius, color);
684 }
685
686 void DrawCircle(::Vector2 center, int radius,
687 ::Color color = {255, 255, 255, 255}) {
688 ::ImageDrawCircleV(this, center, radius, color);
689 }
690
691 void DrawRectangle(int posX, int posY, int width, int height,
692 ::Color color = {255, 255, 255, 255}) {
693 ::ImageDrawRectangle(this, posX, posY, width, height, color);
694 }
695
696 void DrawRectangle(Vector2 position, Vector2 size,
697 ::Color color = {255, 255, 255, 255}) {
698 ::ImageDrawRectangleV(this, position, size, color);
699 }
700
701 void DrawRectangle(::Rectangle rec, ::Color color = {255, 255, 255, 255}) {
702 ::ImageDrawRectangleRec(this, rec, color);
703 }
704
705 void DrawRectangleLines(::Rectangle rec, int thick = 1,
706 ::Color color = {255, 255, 255, 255}) {
707 ::ImageDrawRectangleLines(this, rec, thick, color);
708 }
709
710 void Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec,
711 ::Color tint = {255, 255, 255, 255}) {
712 ::ImageDraw(this, src, srcRec, dstRec, tint);
713 }
714
715 void DrawText(const char* text, ::Vector2 position, int fontSize,
716 ::Color color = {255, 255, 255, 255}) {
717 ::ImageDrawText(this,
718 text,
719 static_cast<int>(position.x),
720 static_cast<int>(position.y),
721 fontSize,
722 color);
723 }
724
725 void DrawText(const std::string_view text, ::Vector2 position, int fontSize,
726 ::Color color = {255, 255, 255, 255}) {
727 ::ImageDrawText(this,
728 text.data(),
729 static_cast<int>(position.x),
730 static_cast<int>(position.y),
731 fontSize,
732 color);
733 }
734
735 void DrawText(const std::string_view text, int x, int y, int fontSize,
736 ::Color color = {255, 255, 255, 255}) {
737 ::ImageDrawText(this, text.data(), x, y, fontSize, color);
738 }
739
740 void DrawText(const char* text, int x, int y, int fontSize,
741 ::Color color = {255, 255, 255, 255}) {
742 ::ImageDrawText(this, text, x, y, fontSize, color);
743 }
744
745 void DrawText(const ::Font& font, const std::string_view text, ::Vector2 position,
746 float fontSize, float spacing, ::Color tint = {255, 255, 255, 255}) {
747 ::ImageDrawTextEx(this, font, text.data(), position, fontSize, spacing, tint);
748 }
749
750 void DrawText(const ::Font& font, const char* text, ::Vector2 position,
751 float fontSize, float spacing, ::Color tint = {255, 255, 255, 255}) {
752 ::ImageDrawTextEx(this, font, text, position, fontSize, spacing, tint);
753 }
754
758 ::Color* LoadColors() const {
759 return ::LoadImageColors(*this);
760 }
761
765 ::Color* LoadPalette(int maxPaletteSize, int *colorsCount) const {
766 return ::LoadImagePalette(*this, maxPaletteSize, colorsCount);
767 }
768
772 void UnloadColors(::Color* colors) const {
773 ::UnloadImageColors(colors);
774 }
775
779 void UnloadPalette(::Color* colors) const {
780 ::UnloadImagePalette(colors);
781 }
782
787 return ::LoadTextureFromImage(*this);
788 }
789
795 operator ::Texture2D() {
796 return LoadTexture();
797 }
798
802 static int GetPixelDataSize(int width, int height, int format = PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) {
803 return ::GetPixelDataSize(width, height, format);
804 }
805
811 int GetPixelDataSize() const {
812 return ::GetPixelDataSize(width, height, format);
813 }
814
820 bool IsReady() const {
821 return ::IsImageReady(*this);
822 }
823
824 protected:
825 void set(const ::Image& image) {
826 data = image.data;
827 width = image.width;
828 height = image.height;
829 mipmaps = image.mipmaps;
830 format = image.format;
831 }
832};
833} // namespace raylib
834
835using RImage = raylib::Image;
836
837#endif // RAYLIB_CPP_INCLUDE_IMAGE_HPP_
Color type, RGBA (32bit)
Definition: Color.hpp:16
Degree type (allows automatic worry free conversion between radians and degrees)
Image type, bpp always RGBA (32bit)
Definition: Image.hpp:19
void Load(const std::string_view fileName, int width, int height, int format, int headerSize)
Load image from RAW file data.
Definition: Image.hpp:241
void Load(const std::string_view fileType, const std::span< unsigned char > fileData)
Load image from memory buffer, fileType refers to extension: i.e.
Definition: Image.hpp:300
Image(const std::string_view fileName, int *frames)
Load an animation image from the given file.
Definition: Image.hpp:62
Image & ColorContrast(float contrast)
Modify image color: contrast.
Definition: Image.hpp:607
Image & Dither(int rBpp, int gBpp, int bBpp, int aBpp)
Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
Definition: Image.hpp:531
::Image WhiteNoise(int width, int height, float factor)
Generate image: white noise.
Definition: Image.hpp:172
Image & ColorTint(::Color color={255, 255, 255, 255})
Modify image color: tint.
Definition: Image.hpp:581
Image & ResizeNN(int newWidth, int newHeight)
Resize and image to new size using Nearest-Neighbor scaling algorithm.
Definition: Image.hpp:506
Image & Rotate(Degree degrees)
Rotate image by input angle in degrees (-359 to 359)
Definition: Image.hpp:557
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:514
::Color * LoadColors() const
Load color data from image as a Color array (RGBA - 32bit)
Definition: Image.hpp:758
::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:164
void Load(const ::Texture2D &texture)
Load an image from the given file.
Definition: Image.hpp:316
::Image Cellular(int width, int height, int tileSize)
Generate image: cellular algorithm.
Definition: Image.hpp:179
Image(const ::Texture2D &texture)
Load an image from the given file.
Definition: Image.hpp:91
Rectangle GetAlphaBorder(float threshold) const
Get image alpha border rectangle.
Definition: Image.hpp:635
::Image FromImage(::Rectangle rec) const
Create an image from another image piece.
Definition: Image.hpp:407
int GetPixelDataSize() const
Returns the pixel data size based on the current image.
Definition: Image.hpp:811
Image(const std::string_view fileName, std::span< int > frames)
Load an animation image from the given file.
Definition: Image.hpp:73
operator::Texture2D()
Loads a texture from the image data.
Definition: Image.hpp:795
Image(const std::string_view fileName)
Load an image from the given file.
Definition: Image.hpp:40
void Load(const std::string_view fileType, const unsigned char *fileData, int dataSize)
Load image from memory buffer, fileType refers to extension: i.e.
Definition: Image.hpp:283
raylib::Color GetColor(::Vector2 position) const
Get image pixel color at vector position.
Definition: Image.hpp:649
bool IsReady() const
Retrieve whether or not the Image has been loaded.
Definition: Image.hpp:820
void SetHeight(int height, int offsetX=0, int offsetY=0, ::Color fill={255, 255, 255, 255})
Set the height of the image canvas.
Definition: Image.hpp:386
::Texture2D LoadTexture() const
Load texture from image data.
Definition: Image.hpp:786
Image & ColorGrayscale()
Modify image color: grayscale.
Definition: Image.hpp:597
void ExportAsCode(const std::string_view fileName) const
Export image as code file defining an array of bytes, returns true on success.
Definition: Image.hpp:360
::Color * LoadPalette(int maxPaletteSize, int *colorsCount) const
Load colors palette from image as a Color array (RGBA - 32bit)
Definition: Image.hpp:765
Image & ColorBrightness(int brightness)
Modify image color: brightness.
Definition: Image.hpp:617
Image & RotateCW()
Rotate image clockwise 90deg.
Definition: Image.hpp:565
Image & FlipHorizontal()
Flip image horizontally.
Definition: Image.hpp:547
Image & AlphaPremultiply()
Premultiply alpha channel.
Definition: Image.hpp:462
Image & ToPOT(::Color fillColor)
Convert image to POT (power-of-two)
Definition: Image.hpp:422
Image & ClearBackground(::Color color={0, 0, 0, 255})
Clear image background with given color.
Definition: Image.hpp:656
Image & Crop(int offsetX, int offsetY, int newWidth, int newHeight)
Crop an image to area defined by a rectangle.
Definition: Image.hpp:484
void Load(const std::string_view fileName, int *frames)
Load image sequence from file (frames appended to image.data).
Definition: Image.hpp:255
::Image Color(int width, int height, ::Color color={255, 255, 255, 255})
Generate image: plain color.
Definition: Image.hpp:142
Image & FlipVertical()
Flip image vertically.
Definition: Image.hpp:539
Image & RotateCCW()
Rotate image counter-clockwise 90deg.
Definition: Image.hpp:573
void Load(const std::string_view fileName)
Load image from file into CPU memory (RAM)
Definition: Image.hpp:227
::Image Copy() const
Create an image duplicate (useful for transformations)
Definition: Image.hpp:400
raylib::Color GetColor(int x=0, int y=0) const
Get image pixel color at (x, y) position.
Definition: Image.hpp:642
Image & Format(int newFormat)
Convert image data to desired format.
Definition: Image.hpp:414
Image & AlphaCrop(float threshold)
Crop image depending on alpha value.
Definition: Image.hpp:438
::Vector2 GetSize() const
Retrieve the width and height of the image.
Definition: Image.hpp:393
static int GetPixelDataSize(int width, int height, int format=PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)
Get pixel data size in bytes for certain format.
Definition: Image.hpp:802
unsigned char * ExportToMemory(const char *fileType, int *fileSize)
Export image to memory buffer.
Definition: Image.hpp:347
Image(const std::string_view fileName, int width, int height, int format, int headerSize=0)
Load a raw image from the given file, with the provided width, height, and formats.
Definition: Image.hpp:51
::Image GradientRadial(int width, int height, float density, ::Color inner, ::Color outer)
Generate image: radial gradient.
Definition: Image.hpp:156
Image & Mipmaps()
Generate all mipmap levels for a provided image.
Definition: Image.hpp:523
Image & AlphaMask(const ::Image &alphaMask)
Apply alpha mask to image.
Definition: Image.hpp:454
::Image LoadFromScreen()
Get pixel data from screen buffer and return an Image (screenshot)
Definition: Image.hpp:135
Image & ColorInvert()
Modify image color: invert.
Definition: Image.hpp:589
void Unload()
Unload image from CPU memory (RAM)
Definition: Image.hpp:326
Image & Crop(int newWidth, int newHeight)
Crop an image to a new given width and height.
Definition: Image.hpp:470
Image(const std::string_view fileType, const unsigned char *fileData, int dataSize)
Load an image from the given file.
Definition: Image.hpp:82
void Export(const std::string_view fileName) const
Export image data to file, returns true on success.
Definition: Image.hpp:338
void UnloadColors(::Color *colors) const
Unload color data loaded with LoadImageColors()
Definition: Image.hpp:772
void SetWidth(int width, int offsetX=0, int offsetY=0, ::Color fill={255, 255, 255, 255})
Set the width of the image canvas.
Definition: Image.hpp:377
::Image GradientLinear(int width, int height, int direction, ::Color start, ::Color end)
Generate image: linear gradient.
Definition: Image.hpp:149
Image & ColorReplace(::Color color, ::Color replace)
Modify image color: replace color.
Definition: Image.hpp:625
Image & AlphaClear(::Color color, float threshold)
Clear alpha channel to desired color.
Definition: Image.hpp:446
Image & Crop(::Rectangle crop)
Crop an image to area defined by a rectangle.
Definition: Image.hpp:430
void DrawPixel(int posX, int posY, ::Color color={255, 255, 255, 255})
Draw pixel within an image.
Definition: Image.hpp:664
void UnloadPalette(::Color *colors) const
Unload colors palette loaded with LoadImagePalette()
Definition: Image.hpp:779
Image & Resize(int newWidth, int newHeight)
Resize and image to new size.
Definition: Image.hpp:498
Image & Crop(::Vector2 size)
Crop an image to a new given width and height based on a vector.
Definition: Image.hpp:477
void Load(const std::string_view fileName, std::span< int > frames)
Load image sequence from file (frames appended to image.data).
Definition: Image.hpp:269
Exception used for most raylib-related exceptions.
Rectangle type.
Definition: Rectangle.hpp:14