WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.17' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714515325.0702760219573974609375', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
“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.<\/strong><\/p>\n <\/p>\n The GetPixelDataAsync<\/a> method of the BitmapDecoder<\/a> 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.<\/p>\n [csharp] using (var stream = await file.OpenAsync(FileAccessMode.Read)) \/\/Create a transform to get a 1×1 image \/\/Get the pixel provider \/\/Get the bytes of the 1×1 scaled image \/\/read the color [\/csharp]<\/p>\n
\n\/\/get the file
\nvar file = await StorageFile.GetFileFromApplicationUriAsync(myLocalImageUri);<\/p>\n
\n{
\n \/\/Create a decoder for the image
\n var decoder = await BitmapDecoder.CreateAsync(stream);<\/p>\n
\n var myTransform = new BitmapTransform { ScaledHeight = 1, ScaledWidth = 1 };<\/p>\n
\n var pixels = await decoder.GetPixelDataAsync(
\n BitmapPixelFormat.Rgba8,
\n BitmapAlphaMode.Ignore,
\n myTransform ,
\n ExifOrientationMode.IgnoreExifOrientation,
\n ColorManagementMode.DoNotColorManage);<\/p>\n
\n var bytes = pixels.DetachPixelData();<\/p>\n
\n var myDominantColor = Color.FromArgb(255, bytes[0], bytes[1], bytes[2]);
\n}<\/p>\n