CSharp examples for System.Drawing:Image Operation
Checks if an image has varying RGB values among pixels that are partially or fully opaque.
using System.Windows.Forms; using System.Text; using System.Linq; using System.Drawing; using System.Collections.Generic; using System;/*ww w .jav a 2 s . co m*/ public class Main{ /// <summary> /// Checks if an image has varying RGB values among pixels that are partially or fully opaque. /// </summary> public static bool HasNonAlpha(Bitmap bmp) { int? found = null; for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { Color color = bmp.GetPixel(x, y); if (color.A == 0) continue; int rgb = color.ToArgb() & 0xFFFFFF; if (found == null) { found = rgb; } else if (rgb != found) { return true; } } } return false; } }