 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
1 #ifndef RAYLIB_CPP_IMAGE_HPP_
2 #define RAYLIB_CPP_IMAGE_HPP_
13 #include "./raylib-cpp-utils.hpp"
22 Image(
const std::string& fileName) {
25 Image(
const std::string& fileName,
int width,
int height,
int format,
int headerSize) {
26 LoadRaw(fileName, width, height, format, headerSize);
28 Image(
const std::string& fileName,
int* frames) {
32 set(::GetTextureData(texture));
35 set(::GenImageColor(width, height, color));
39 return ::ImageText(text.c_str(), fontSize, color);
43 return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
51 return ::GenImageColor(width, height, color);
55 return ::GenImageGradientV(width, height, top, bottom);
59 return ::GenImageGradientH(width, height, left, right);
63 return ::GenImageGradientRadial(width, height, density, inner, outer);
67 return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
71 return ::GenImageWhiteNoise(width, height, factor);
75 return ::GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
79 return ::GenImageCellular(width, height, tileSize);
99 height = image.height;
100 mipmaps = image.mipmaps;
101 format = image.format;
104 void Load(
const std::string& fileName) {
105 set(::LoadImage(fileName.c_str()));
108 void LoadRaw(
const std::string& fileName,
int width,
int height,
int format,
int headerSize) {
109 set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
112 void LoadAnim(
const std::string& fileName,
int* frames) {
113 set(::LoadImageAnim(fileName.c_str(), frames));
117 ::UnloadImage(*
this);
121 ::ExportImage(*
this, fileName.c_str());
125 ::ExportImageAsCode(*
this, fileName.c_str());
129 GETTERSETTER(
void*,Data,data)
130 GETTERSETTER(
int,Width,width)
131 GETTERSETTER(
int,Height,height)
136 return ::ImageCopy(*
this);
139 return ::ImageFromImage(*
this, rec);
143 ::ImageToPOT(
this, fillColor);
148 ::ImageFormat(
this, newFormat);
153 ::ImageAlphaMask(
this, alphaMask);
158 ::ImageAlphaCrop(
this, threshold);
163 ::ImageAlphaPremultiply(
this);
168 ::ImageCrop(
this, crop);
172 ::ImageResize(
this, newWidth, newHeight);
176 ::ImageResizeNN(
this, newWidth, newHeight);
180 ::ImageResizeCanvas(
this, newWidth, newHeight, offsetX, offsetY, color);
184 ::ImageMipmaps(
this);
188 ::ImageDither(
this, rBpp, gBpp, bBpp, aBpp);
193 ::ImageFlipVertical(
this);
197 ::ImageFlipHorizontal(
this);
202 ::ImageRotateCW(
this);
206 ::ImageRotateCCW(
this);
210 ::ImageColorTint(
this, color);
214 ::ImageColorInvert(
this);
218 ::ImageColorGrayscale(
this);
222 ::ImageColorContrast(
this, contrast);
226 ::ImageColorBrightness(
this, brightness);
230 ::ImageColorReplace(
this, color, replace);
234 inline ::Color*
GetPalette(
int maxPaletteSize,
int *extractCount) {
235 return ::GetImagePalette(*
this, maxPaletteSize, extractCount);
239 return ::GetImageAlphaBorder(*
this, threshold);
243 ::ImageClearBackground(
this, color);
248 ::ImageDrawPixel(
this, posX, posY, color);
253 ::ImageDrawPixelV(
this, position, color);
258 ::ImageDrawLine(
this, startPosX, startPosY, endPosX, endPosY, color);
263 ::ImageDrawLineV(
this, start, end, color);
268 ::ImageDrawCircle(
this, centerX, centerY, radius, color);
273 ::ImageDrawCircleV(
this, center, radius, color);
277 ::ImageDrawRectangle(
this, posX, posY, width, height, color);
281 ::ImageDrawRectangleV(
this, position, size, color);
285 ::ImageDrawRectangleRec(
this, rec, color);
289 ::ImageDrawRectangleLines(
this, rec, thick, color);
293 ::ImageDraw(
this, src, srcRec, dstRec, tint);
298 ::ImageDrawText(
this, text.c_str(), (
int)position.x, (
int)position.y, fontSize, color);
302 ::ImageDrawText(
this, text.c_str(), x, y, fontSize, color);
306 ::ImageDrawTextEx(
this, font, text.c_str(), position, fontSize, spacing, tint);
311 return ::GetImageData(*
this);
315 return ::GetImageDataNormalized(*
this);
318 return ::LoadTextureFromImage(*
this);
Image & Dither(int rBpp, int gBpp, int bBpp, int aBpp)
Provides all the classes associated with raylib-cpp.
Image & DrawRectangle(Vector2 position, Vector2 size, ::Color color=WHITE)
Image & ColorBrightness(int brightness)
Image(::Texture2D texture)
inline ::Color * GetImageData()
Image & Format(int newFormat)
static Image GenGradientV(int width, int height, Color top, Color bottom)
inline ::Color * GetPalette(int maxPaletteSize, int *extractCount)
Image & DrawText(const std::string &text, ::Vector2 position, int fontSize, ::Color color=WHITE)
Image & ToPOT(Color fillColor)
Image & Crop(::Rectangle crop)
Image & ExportAsCode(const std::string &fileName)
Image(const std::string &fileName)
inline ::Vector4 * GetImageDataNormalized()
static Image GenGradientH(int width, int height, Color left, Color right)
static Image GenWhiteNoise(int width, int height, float factor)
Image & DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, ::Color color)
Image & DrawPixel(int posX, int posY, ::Color color)
Image & DrawRectangle(int posX, int posY, int width, int height, ::Color color=WHITE)
Image & ColorContrast(float contrast)
Image & DrawRectangleLines(::Rectangle rec, int thick, ::Color color)
Image & ClearBackground(::Color color=WHITE)
Image & DrawCircle(::Vector2 center, int radius, ::Color color)
void LoadRaw(const std::string &fileName, int width, int height, int format, int headerSize)
Image & operator=(const ::Image &image)
Image & AlphaPremultiply()
static Image GetScreenData()
Image & DrawText(::Font font, const std::string &text, ::Vector2 position, float fontSize, float spacing, ::Color tint=WHITE)
Image(const std::string &fileName, int width, int height, int format, int headerSize)
Image & DrawPixel(::Vector2 position, ::Color color)
static Image Text(std::string text, int fontSize, Color color)
static Image GenGradientRadial(int width, int height, float density, Color inner, Color outer)
static Image GenPerlinNoise(int width, int height, int offsetX, int offsetY, float scale)
void LoadAnim(const std::string &fileName, int *frames)
Image & AlphaMask(Image alphaMask)
void Load(const std::string &fileName)
Image(const std::string &fileName, int *frames)
Image & DrawText(const std::string &text, int x, int y, int fontSize, ::Color color=WHITE)
Image & ColorTint(::Color color=WHITE)
Rectangle GetAlphaBorder(float threshold)
Image & AlphaCrop(float threshold)
Image & Resize(int newWidth, int newHeight)
static Image GenCellular(int width, int height, int tileSize)
Image & ResizeCanvas(int newWidth, int newHeight, int offsetX, int offsetY, Color color)
Image & DrawCircle(int centerX, int centerY, int radius, ::Color color)
Image & ResizeNN(int newWidth, int newHeight)
Image(int width, int height, Color color=WHITE)
Image & operator=(const Image &image)
Image & Export(const std::string &fileName)
static Image GenChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
static Image Text(Font font, std::string text, float fontSize, float spacing, Color tint)
Image & Draw(::Image &src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint=WHITE)
Image & DrawLine(::Vector2 start, ::Vector2 end, ::Color color)
Image & ColorReplace(::Color color, ::Color replace)
Image & DrawRectangle(::Rectangle rec, ::Color color=WHITE)
Image FromImage(::Rectangle rec)
static Image GenColor(int width, int height, Color color)