[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sun, 2009-01-18 at 13:24 -0200, frederico schardong wrote:
> Thank you so.
>
> I'm trying this:
> for(x = 0; x < imagem->w; x++)
> for(y = 0; y < imagem->h; y++){
> matrizRgb[x][y].r = 0.299 * getr(matrizPixel[x][y]);
> matrizRgb[x][y].g = 0.587 * getg(matrizPixel[x][y]);
> matrizRgb[x][y].b = 0.114 * getb(matrizPixel[x][y]);
> matrizPixel[x][y] = makecol(matrizRgb[x][y].r,
> matrizRgb[x][y].g, matrizRgb[x][y].b);
> }
>
> and after save the new picture in gray scale, but it isn't in gray
> scale...
Probably you want something like:
luminance = 0.299 * getr(matrizPixel[x][y]) + 0.587 * getg(matrizPixel[x][y]) + 0.114 * getb(matrizPixel[x][y]);
matrizRgb[x][y].r = luminance;
matrizRgb[x][y].g = luminance;
matrizRgb[x][y].b = luminance;
--
Elias Pschernig <elias@xxxxxxxxxx>