locked
Get RGB Colors Percentage In Bitmap Image RRS feed

  • Question

  • How To Get RGB Color Percentage From Image In Windows App Store By Using Writable Bitmap.

    In Windows App I Was Getting Earlier Like This Way

    public static Color getDominantColor(Bitmap bmp)
    {
           //Used for tally
           int r = 0;
           int g = 0;
           int b = 0;
    
         int total = 0;
    
         for (int x = 0; x < bmp.Width; x++)
         {
              for (int y = 0; y < bmp.Height; y++)
              {
                   Color clr = bmp.GetPixel(x, y);
    
                   r += clr.R;
                   g += clr.G;
                   b += clr.B;
    
                   total++;
              }
         }
    
         //Calculate average
         r /= total;
         g /= total;
         b /= total;
    
         return Color.FromArgb(r, g, b);
    }

    How To Do With Writable Bitmap In Metro App

    Monday, August 19, 2013 7:12 PM

Answers

  • The solution in this thread shows how to get to pixel data for analysis or manipulation.
    • Proposed as answer by Anne Jing Tuesday, August 20, 2013 1:56 PM
    • Marked as answer by Anne Jing Friday, August 23, 2013 5:20 AM
    Monday, August 19, 2013 8:22 PM