| 1 | #ifndef ENGINE_GFX_IMAGE_MANIPULATION_H |
| 2 | #define ENGINE_GFX_IMAGE_MANIPULATION_H |
| 3 | |
| 4 | #include <engine/image.h> |
| 5 | |
| 6 | #include <cstdint> |
| 7 | |
| 8 | // Destination must have appropriate size for RGBA data |
| 9 | bool ConvertToRgba(uint8_t *pDest, const CImageInfo &SourceImage); |
| 10 | // Allocates appropriate buffer with malloc, must be freed by caller |
| 11 | bool ConvertToRgbaAlloc(uint8_t *&pDest, const CImageInfo &SourceImage); |
| 12 | // Replaces existing image data with RGBA data (unless already RGBA) |
| 13 | bool ConvertToRgba(CImageInfo &Image); |
| 14 | |
| 15 | // Changes the image data (not the format) |
| 16 | void ConvertToGrayscale(const CImageInfo &Image); |
| 17 | void ConvertToGrayscaleRect(const CImageInfo &Image, size_t StartX, size_t StartY, size_t Width, size_t Height); |
| 18 | |
| 19 | // Color a rectangle inside an image with hue and saturation |
| 20 | void ColorizeWithHueRect(CImageInfo &Image, float Hue, float Sat, size_t StartX, size_t StartY, size_t Width, size_t Height); |
| 21 | |
| 22 | // These functions assume that the image data is 4 bytes per pixel RGBA |
| 23 | void DilateImage(uint8_t *pImageBuff, int w, int h); |
| 24 | void DilateImage(const CImageInfo &Image); |
| 25 | void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int SubWidth, int SubHeight); |
| 26 | |
| 27 | // Returned buffer is allocated with malloc, must be freed by caller |
| 28 | uint8_t *ResizeImage(const uint8_t *pImageData, int Width, int Height, int NewWidth, int NewHeight, int BPP); |
| 29 | // Replaces existing image data with resized buffer |
| 30 | void ResizeImage(CImageInfo &Image, int NewWidth, int NewHeight); |
| 31 | |
| 32 | int HighestBit(int OfVar); |
| 33 | |
| 34 | #endif // ENGINE_GFX_IMAGE_MANIPULATION_H |
| 35 | |