int rgb; Color pixel; for ( int x = 0; x < bmp.Width; x++ ) { for ( int y = 0; y < bmp.Height; y++ ) { pixel = bmp.GetPixel( x, y ); rgb = ( pixel.R + pixel.G + pixel.B ) / 3; bmp.SetPixel( x, y, Color.FromArgb( rgb, rgb, rgb ) ); } }
public static bool GrayScale(Bitmap bmp) { try { for(int y = 0; y < bmp.Height; y++) { for(int x = 0;x < bmp.Width; x++) { Color c = bmp.GetPixel(x, y); int luma = (int)(c.R * 0.3 + c.G * 0.59+ c.B * 0.11); bmp.SetPixel(x, y, Color.FromArgb(luma,luma,luma)); } } return true; } catch(Exception){ return false; } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
19 sept. 2018 à 14:05
19 sept. 2018 à 14:06
19 sept. 2018 à 14:06
:)
:):
:):
:)::):
:):
:):
:):