(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

WinRT - how to easily get the dominant color of a picture

(0 votes)
0 comments   /   posted by Silverlight Show on Jul 17, 2013
Tags:   windows-8 , winrt , jonathan-antoine
Read original post at Jonathan Antoine's Blog

“Content before Chrome” is the Leitmotif of Windows Store Apps. You’ll usually end up using a lot of images in your app and getting the dominant color of a picture may actually be useful. My first attempt to achieve this was to get the bytes of the picture and calculate the average value. There is actually an easier and faster solution using the Windows Rutime API.


The GetPixelDataAsync method of the BitmapDecoder class lets you get the pixels of a given picture and you can apply transformations during the process. I will the simply ask it to resize the image to a simple unique pixel. The resulting pixel will be the dominant color of the image.


Comments

No comments

Add Comment

Login to comment:
  *      *       

Our News on Twitter