mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[NEW] Function to invert all the colors of an image
This commit is contained in:
parent
3b9d414405
commit
4349944ae7
3 changed files with 3864 additions and 3845 deletions
|
@ -514,7 +514,7 @@ void GRRLIB_FlushTex(GRRLIB_texImg tex)
|
|||
* @param texsrc the texture source.
|
||||
* @param texdest the texture grayscaled destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_GrayScale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y;
|
||||
u8 gray;
|
||||
u32 color;
|
||||
|
@ -523,7 +523,7 @@ void GRRLIB_BMFX_GrayScale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
for(x=0; x<texsrc.w; x++) {
|
||||
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
gray = ((((color>>8) & 0xFF)*77 + ((color>>16) & 0xFF)*150 + ((color>>24) & 0xFF)*28) / (255));
|
||||
gray = (((color >> 24 & 0xFF)*77 + (color >> 16 & 0xFF)*150 + (color >> 8 & 0xFF)*28) / (255));
|
||||
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
((gray << 24) | (gray << 16) | (gray << 8) | (color & 0xFF)));
|
||||
|
@ -531,6 +531,26 @@ void GRRLIB_BMFX_GrayScale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert colors of the texture.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y;
|
||||
u32 color;
|
||||
|
||||
for(y=0; y<texsrc.h; y++) {
|
||||
for(x=0; x<texsrc.w; x++) {
|
||||
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
((0xFFFFFF - (color >> 8 & 0xFFFFFF)) << 8) | (color & 0xFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A texture effect.
|
||||
* @see GRRLIB_FlushTex
|
||||
|
|
|
@ -67,7 +67,8 @@ void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color);
|
|||
|
||||
void GRRLIB_FlushTex(GRRLIB_texImg tex);
|
||||
|
||||
void GRRLIB_BMFX_GrayScale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest);
|
||||
void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest);
|
||||
void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest);
|
||||
void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor);
|
||||
|
||||
void GRRLIB_GXEngine(Vector v[], u32 color, long count, u8 fmt);
|
||||
|
|
|
@ -56,7 +56,7 @@ ChangeLog :
|
|||
|
||||
* GRRLIB_CreateEmptyTexture and GRRLIB_FlushTex
|
||||
|
||||
* New Bitmap FX: GRRLIB_BMFX_GrayScale and GRRLIB_BMFX_Scatter
|
||||
* New Bitmap FX: GRRLIB_BMFX_Grayscale, GRRLIB_BMFX_Invert and GRRLIB_BMFX_Scatter
|
||||
|
||||
* add GRRLIB_Exit to free the memory allocated by GRRLIB
|
||||
|
||||
|
@ -70,5 +70,3 @@ Contact me to provide me all your patch/addon/new functions...
|
|||
NoNameNo.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue