Added: ImageResizeCanvas() -WIP-
Added note idea on ImageFormat() for future redesign (to support 16bit-32bit pixel-formats)
This commit is contained in:
parent
129c890a28
commit
2536bea379
2 changed files with 18 additions and 2 deletions
|
@ -912,8 +912,9 @@ RLAPI void ImageAlphaClear(Image *image, Color color, float threshold);
|
||||||
RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value
|
RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value
|
||||||
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
|
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 ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering)
|
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (bilinear filtering)
|
||||||
RLAPI void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and 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 anchor, Color color); // Resize canvas, using anchor point and color filling
|
||||||
RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image
|
RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image
|
||||||
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
||||||
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)
|
||||||
|
|
|
@ -664,6 +664,7 @@ void ImageFormat(Image *image, int newFormat)
|
||||||
if ((image->format < COMPRESSED_DXT1_RGB) && (newFormat < COMPRESSED_DXT1_RGB))
|
if ((image->format < COMPRESSED_DXT1_RGB) && (newFormat < COMPRESSED_DXT1_RGB))
|
||||||
{
|
{
|
||||||
Color *pixels = GetImageData(*image);
|
Color *pixels = GetImageData(*image);
|
||||||
|
//Vector4 *pixels = GetImageDataNormalized(*image); // TODO: Support 8->32bit channels
|
||||||
|
|
||||||
free(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end...
|
free(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end...
|
||||||
image->data = NULL;
|
image->data = NULL;
|
||||||
|
@ -1066,6 +1067,20 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight)
|
||||||
free(pixels);
|
free(pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resize canvas, using anchor point and color filling
|
||||||
|
void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int anchor, Color color)
|
||||||
|
{
|
||||||
|
Image imTemp = GenImageColor(newWidth, newHeight, color);
|
||||||
|
Rectangle rec = { 0, 0, image->width, image->height };
|
||||||
|
|
||||||
|
// TODO: consider anchor properly
|
||||||
|
|
||||||
|
ImageDraw(&imTemp, *image, rec, rec);
|
||||||
|
ImageFormat(&imTemp, image->format);
|
||||||
|
UnloadImage(*image);
|
||||||
|
*image = imTemp;
|
||||||
|
}
|
||||||
|
|
||||||
// Generate all mipmap levels for a provided image
|
// Generate all mipmap levels for a provided image
|
||||||
// NOTE 1: Supports POT and NPOT images
|
// NOTE 1: Supports POT and NPOT images
|
||||||
// NOTE 2: image.data is scaled to include mipmap levels
|
// NOTE 2: image.data is scaled to include mipmap levels
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue