 |
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);
96 void Load(
const std::string& fileName) {
97 set(::LoadImage(fileName.c_str()));
100 void LoadRaw(
const std::string& fileName,
int width,
int height,
int format,
int headerSize) {
101 set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
104 void LoadAnim(
const std::string& fileName,
int* frames) {
105 set(::LoadImageAnim(fileName.c_str(), frames));
109 ::UnloadImage(*
this);
113 ::ExportImage(*
this, fileName.c_str());
117 ::ExportImageAsCode(*
this, fileName.c_str());
121 GETTERSETTER(
void*,Data,data)
122 GETTERSETTER(
int,Width,width)
123 GETTERSETTER(
int,Height,height)
128 return ::ImageCopy(*
this);
131 return ::ImageFromImage(*
this, rec);
135 ::ImageToPOT(
this, fillColor);
140 ::ImageFormat(
this, newFormat);
145 ::ImageAlphaMask(
this, alphaMask);
150 ::ImageAlphaCrop(
this, threshold);
155 ::ImageAlphaPremultiply(
this);
160 ::ImageCrop(
this, crop);
163 inline Image&
Crop(
int offsetX,
int offsetY,
int newWidth,
int newHeight) {
164 ::ImageCrop(
this, (
Rectangle){ (float)offsetX, (
float)offsetY, (float)newWidth, (
float)newHeight });
169 ::ImageResize(
this, newWidth, newHeight);
173 ::ImageResizeNN(
this, newWidth, newHeight);
178 ::ImageResizeCanvas(
this, newWidth, newHeight, offsetX, offsetY, color);
183 ::ImageMipmaps(
this);
188 ::ImageDither(
this, rBpp, gBpp, bBpp, aBpp);
193 ::ImageFlipVertical(
this);
197 ::ImageFlipHorizontal(
this);
202 ::ImageRotateCW(
this);
207 ::ImageRotateCCW(
this);
212 ::ImageColorTint(
this, color);
217 ::ImageColorInvert(
this);
222 ::ImageColorGrayscale(
this);
226 ::ImageColorContrast(
this, contrast);
230 ::ImageColorBrightness(
this, brightness);
234 ::ImageColorReplace(
this, color, replace);
238 inline ::Color*
GetPalette(
int maxPaletteSize,
int *extractCount) {
239 return ::GetImagePalette(*
this, maxPaletteSize, extractCount);
243 return ::GetImageAlphaBorder(*
this, threshold);
247 ::ImageClearBackground(
this, color);
252 ::ImageDrawPixel(
this, posX, posY, color);
257 ::ImageDrawPixelV(
this, position, color);
262 ::ImageDrawLine(
this, startPosX, startPosY, endPosX, endPosY, color);
267 ::ImageDrawLineV(
this, start, end, color);
272 ::ImageDrawCircle(
this, centerX, centerY, radius, color);
277 ::ImageDrawCircleV(
this, center, radius, color);
281 ::ImageDrawRectangle(
this, posX, posY, width, height, color);
285 ::ImageDrawRectangleV(
this, position, size, color);
289 ::ImageDrawRectangleRec(
this, rec, color);
293 ::ImageDrawRectangleLines(
this, rec, thick, color);
297 ::ImageDraw(
this, src, srcRec, dstRec, tint);
302 ::ImageDrawText(
this, text.c_str(), (
int)position.x, (
int)position.y, fontSize, color);
306 ::ImageDrawText(
this, text.c_str(), x, y, fontSize, color);
310 ::ImageDrawTextEx(
this, font, text.c_str(), position, fontSize, spacing, tint);
315 return ::GetImageData(*
this);
319 return ::GetImageDataNormalized(*
this);
322 return ::LoadTextureFromImage(*
this);
329 height = image.height;
330 mipmaps = image.mipmaps;
331 format = image.format;
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()
Image & Crop(int offsetX, int offsetY, int newWidth, int newHeight)
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)
Rectangle GetAlphaBorder(float threshold) const
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)
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)