小编Stu*_*ton的帖子

UWP的BitmapImage到流

我有一个使用转换器在XAML加载的图像。而不是负载这一形象再次,我要采取的图像,并找到主色,以便能够使用网页上的其他图形。到目前为止,我有这个:

var himage = (BitmapImage)image_home.Source;

using (var stream = await himage.OpenReadAsync())  //**can't open himage this way**
    {
      //Create a decoder for the image
         var decoder = await BitmapDecoder.CreateAsync(stream);

      //Create a transform to get a 1x1 image
         var myTransform = new BitmapTransform { ScaledHeight = 1, ScaledWidth = 1 };

      //Get the pixel provider
         var pixels = await decoder.GetPixelDataAsync(
         BitmapPixelFormat.Rgba8,
         BitmapAlphaMode.Ignore,
         myTransform,
         ExifOrientationMode.IgnoreExifOrientation,
         ColorManagementMode.DoNotColorManage);

      //Get the bytes of the 1x1 scaled image
         var bytes = pixels.DetachPixelData();

      //read the color 
         var myDominantColor …
Run Code Online (Sandbox Code Playgroud)

c# memorystream bitmapimage uwp

6
推荐指数
1
解决办法
2854
查看次数

Perl正则表达式匹配问题

我想我在这里错过了一些简单的东西......

$key = "deco-1-LB-700F:MAR:40";
  if ($key =~ m/deco-(.*?)-(.*?)-(.*?):(.*?):(.*?)/) {
      print "1=$1 2=$2 3=$3 4=$4 5=$5";
  }
Run Code Online (Sandbox Code Playgroud)

这导致输出:1 = 1 2 = LB 3 = 700F 4 = MAR 5 =

为什么$ 5不能返回值40?

干杯,斯图

regex perl

2
推荐指数
1
解决办法
179
查看次数

标签 统计

bitmapimage ×1

c# ×1

memorystream ×1

perl ×1

regex ×1

uwp ×1