Преглед на файлове

Added function: ImageColorReplace()

pull/565/head
Ray преди 6 години
родител
ревизия
74fd0e7ca4
променени са 4 файла, в които са добавени 32 реда и са изтрити 0 реда
  1. +1
    -0
      release/include/raylib.h
  2. Двоични данни
      release/libs/win32/mingw32/libraylib.a
  3. +1
    -0
      src/raylib.h
  4. +30
    -0
      src/textures.c

+ 1
- 0
release/include/raylib.h Целия файл

@ -937,6 +937,7 @@ RLAPI void ImageColorInvert(Image *image);
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
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 ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color
// Image generation functions
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color

Двоични данни
release/libs/win32/mingw32/libraylib.a Целия файл


+ 1
- 0
src/raylib.h Целия файл

@ -937,6 +937,7 @@ RLAPI void ImageColorInvert(Image *image);
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
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 ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color
// Image generation functions
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color

+ 30
- 0
src/textures.c Целия файл

@ -1901,6 +1901,36 @@ void ImageColorBrightness(Image *image, int brightness)
image->data = processed.data;
}
// Modify image color: replace color
void ImageColorReplace(Image *image, Color color, Color replace)
{
Color *pixels = GetImageData(*image);
for (int y = 0; y < image->height; y++)
{
for (int x = 0; x < image->width; x++)
{
if ((pixels[y*image->width + x].r == color.r) &&
(pixels[y*image->width + x].g == color.g) &&
(pixels[y*image->width + x].b == color.b) &&
(pixels[y*image->width + x].a == color.a))
{
pixels[y*image->width + x].r = replace.r;
pixels[y*image->width + x].g = replace.g;
pixels[y*image->width + x].b = replace.b;
pixels[y*image->width + x].a = replace.a;
}
}
}
Image processed = LoadImageEx(pixels, image->width, image->height);
ImageFormat(&processed, image->format);
UnloadImage(*image);
free(pixels);
image->data = processed.data;
}
#endif // SUPPORT_IMAGE_MANIPULATION
#if defined(SUPPORT_IMAGE_GENERATION)

Зареждане…
Отказ
Запис