*Added Grayscalefunction to the GuiImage Class

*Added svnrev.c to ignore list to avoid conflicts
This commit is contained in:
dimok321 2009-07-30 20:35:39 +00:00
parent 4147f980dc
commit 45f2cb9704
3 changed files with 26 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -636,6 +636,8 @@ class GuiImage : public GuiElement
//!\param y Y coordinate //!\param y Y coordinate
//!\param color Pixel color //!\param color Pixel color
void SetPixel(int x, int y, GXColor color); void SetPixel(int x, int y, GXColor color);
//!Sets the image to grayscale
void SetGrayscale(void);
//!Directly modifies the image data to create a color-striped effect //!Directly modifies the image data to create a color-striped effect
//!Alters the RGB values by the specified amount //!Alters the RGB values by the specified amount
//!\param s Amount to increment/decrement the RGB values in the image //!\param s Amount to increment/decrement the RGB values in the image

View File

@ -288,6 +288,29 @@ void GuiImage::SetPixel(int x, int y, GXColor color)
*(image+offset+33) = color.b; *(image+offset+33) = color.b;
} }
void GuiImage::SetGrayscale(void)
{
LOCK(this);
GXColor color;
u32 offset, gray;
for(int x = 0; x < width; x++) {
for(int y = 0; y < height; y++) {
offset = (((y >> 2)<<4)*this->GetWidth()) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1);
color.r = *(image+offset+1);
color.g = *(image+offset+32);
color.b = *(image+offset+33);
gray = (77*color.r + 150*color.g + 28*color.b)/255;
*(image+offset+1) = gray;
*(image+offset+32) = gray;
*(image+offset+33) = gray;
}
}
}
void GuiImage::SetStripe(int s) void GuiImage::SetStripe(int s)
{ {
LOCK(this); LOCK(this);