Reorganized texture functions
Removed ImageAlphaMask() dependency on [text] LoadBMFont()
This commit is contained in:
parent
4e29294caa
commit
959447d8ed
4 changed files with 1357 additions and 1326 deletions
|
@ -98,11 +98,14 @@
|
||||||
|
|
||||||
// Support image export functionality (.png, .bmp, .tga, .jpg)
|
// Support image export functionality (.png, .bmp, .tga, .jpg)
|
||||||
#define SUPPORT_IMAGE_EXPORT 1
|
#define SUPPORT_IMAGE_EXPORT 1
|
||||||
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
|
|
||||||
// If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()
|
|
||||||
#define SUPPORT_IMAGE_MANIPULATION 1
|
|
||||||
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
|
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
|
||||||
#define SUPPORT_IMAGE_GENERATION 1
|
#define SUPPORT_IMAGE_GENERATION 1
|
||||||
|
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
|
||||||
|
// If not defined only three image editing functions supported: ImageFormat(), ImageCrop(), ImageToPOT()
|
||||||
|
#define SUPPORT_IMAGE_MANIPULATION 1
|
||||||
|
// Support drawing on image (software rendering)
|
||||||
|
#define SUPPORT_IMAGE_DRAWING 1
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module: text - Configuration Flags
|
// Module: text - Configuration Flags
|
||||||
|
|
15
src/raylib.h
15
src/raylib.h
|
@ -1110,8 +1110,6 @@ RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format
|
||||||
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
||||||
RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file
|
RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file
|
||||||
RLAPI void ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes
|
RLAPI void ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes
|
||||||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
|
||||||
RLAPI Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized)
|
|
||||||
|
|
||||||
// Image generation functions
|
// Image generation functions
|
||||||
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
|
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
|
||||||
|
@ -1128,13 +1126,13 @@ RLAPI Image ImageCopy(Image image);
|
||||||
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
|
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
|
||||||
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
|
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
|
||||||
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
|
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
|
||||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
|
||||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||||
RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color
|
|
||||||
RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value
|
|
||||||
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
|
|
||||||
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
|
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
|
||||||
|
RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value
|
||||||
|
RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color
|
||||||
|
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||||
|
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
|
||||||
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
|
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
|
||||||
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
|
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
|
||||||
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); // Resize canvas and fill with color
|
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); // Resize canvas and fill with color
|
||||||
|
@ -1150,7 +1148,10 @@ RLAPI void ImageColorGrayscale(Image *image);
|
||||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||||
RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color
|
RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color
|
||||||
|
|
||||||
|
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||||
RLAPI Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount); // Extract color palette from image to maximum size (memory should be freed)
|
RLAPI Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount); // Extract color palette from image to maximum size (memory should be freed)
|
||||||
|
RLAPI Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized)
|
||||||
RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle
|
RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle
|
||||||
|
|
||||||
// Image drawing functions
|
// Image drawing functions
|
||||||
|
|
13
src/text.c
13
src/text.c
|
@ -1733,8 +1733,17 @@ static Font LoadBMFont(const char *fileName)
|
||||||
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
|
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
|
||||||
{
|
{
|
||||||
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
|
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
|
||||||
ImageAlphaMask(&imFont, imFont);
|
Image imFontAlpha = ImageCopy(imFont);
|
||||||
for (int p = 0; p < (imFont.width*imFont.height*2); p += 2) ((unsigned char *)(imFont.data))[p] = 0xff;
|
ImageFormat(&imFontAlpha, UNCOMPRESSED_GRAY_ALPHA);
|
||||||
|
|
||||||
|
for (int p = 0, i = 0; p < (imFont.width*imFont.height*2); p += 2, i++)
|
||||||
|
{
|
||||||
|
((unsigned char *)(imFontAlpha.data))[p] = 0xff;
|
||||||
|
((unsigned char *)(imFontAlpha.data))[p + 1] = ((unsigned char *)imFont.data)[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
UnloadImage(imFont);
|
||||||
|
imFont = imFontAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
font.texture = LoadTextureFromImage(imFont);
|
font.texture = LoadTextureFromImage(imFont);
|
||||||
|
|
2644
src/textures.c
2644
src/textures.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue