| 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 | |
| 18 | // These functions assume that the image data is 4 bytes per pixel RGBA |
| 19 | void DilateImage(uint8_t *pImageBuff, int w, int h); |
| 20 | void DilateImage(const CImageInfo &Image); |
| 21 | void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int SubWidth, int SubHeight); |
| 22 | |
| 23 | // Returned buffer is allocated with malloc, must be freed by caller |
| 24 | uint8_t *ResizeImage(const uint8_t *pImageData, int Width, int Height, int NewWidth, int NewHeight, int BPP); |
| 25 | // Replaces existing image data with resized buffer |
| 26 | void ResizeImage(CImageInfo &Image, int NewWidth, int NewHeight); |
| 27 | |
| 28 | int HighestBit(int OfVar); |
| 29 | |
| 30 | #endif // ENGINE_GFX_IMAGE_MANIPULATION_H |
| 31 | |