当前位置: 首页>>代码示例>>C#>>正文


C# TransformedBitmap.Freeze方法代码示例

本文整理汇总了C#中System.Windows.Media.Imaging.TransformedBitmap.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# TransformedBitmap.Freeze方法的具体用法?C# TransformedBitmap.Freeze怎么用?C# TransformedBitmap.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Imaging.TransformedBitmap的用法示例。


在下文中一共展示了TransformedBitmap.Freeze方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DecreaseImage

        private static async Task<ImageAndSource> DecreaseImage(string inputFile)
        {
            var newLenght = maxFileLenght * 3;

            var initialLength = new FileInfo(inputFile).Length;

            var initialImage = await FileToImage(inputFile).ConfigureAwait(false);
            
            while (true)
            {
                using (var scaledImage = new MemoryStream())
                {
                    var scale = Math.Sqrt((((double)newLenght) / initialLength));

                    var transformed = new TransformedBitmap(initialImage, new ScaleTransform(scale, scale));

                    transformed.Freeze();

                    var saver = new JpegBitmapEncoder();

                    saver.Frames.Add(BitmapFrame.Create(transformed));

                    saver.Save(scaledImage);

                    scaledImage.Seek(0, SeekOrigin.Begin);

                    newLenght = newLenght * 4 / 5;

                    if (scaledImage.Length < maxFileLenght)
                    {
                        return new ImageAndSource
                        {
                            image = transformed,
                            source = scaledImage.ToArray()
                        };
                    }
                }
            }
        }
开发者ID:imanushin,项目名称:PhotoDecreaser,代码行数:39,代码来源:PhotoInfo.cs

示例2: CreateFlipped

 public static ImageData CreateFlipped(ImageMetaData info, PixelFormat format, BitmapPalette palette,
                                 byte[] pixel_data, int stride)
 {
     var bitmap = BitmapSource.Create((int)info.Width, (int)info.Height, DefaultDpiX, DefaultDpiY,
                                       format, palette, pixel_data, stride);
     var flipped = new TransformedBitmap(bitmap, new ScaleTransform { ScaleY = -1 });
     flipped.Freeze();
     return new ImageData(flipped, info);
 }
开发者ID:xmoeproject,项目名称:X-moe,代码行数:9,代码来源:Utility.cs

示例3: CreateTransformedBitmap

		private static TransformedBitmap CreateTransformedBitmap(BitmapSource source, VCProfile profile)
		{
			var transformedBitmap = new TransformedBitmap();
			transformedBitmap.BeginInit();
			transformedBitmap.Source = source;
			var transformGroup = new TransformGroup();
			transformGroup.Children.Add(new ScaleTransform(profile.FlipHorizontal ? -1 : 1, profile.FlipVertical ? -1 : 1));
			transformGroup.Children.Add(new RotateTransform(ConvertRotationToDegrees(profile.Rotation)));
			transformedBitmap.Transform = transformGroup;
			transformedBitmap.EndInit();
			transformedBitmap.Freeze();

			return transformedBitmap;
		}
开发者ID:Runcy,项目名称:VidCoder,代码行数:14,代码来源:PreviewViewModel.cs

示例4: MetaOrientation

    private static BitmapSource MetaOrientation(BitmapMetadata meta, BitmapSource ret)
    {
      double angle = 0;
      if ((meta != null) && (ret != null)) //si on a des meta, tentative de récupération de l'orientation
      {
        if (meta.GetQuery("/app1/ifd/{ushort=274}") != null)
        {
          orientation =
            (ExifOrientations)
            Enum.Parse(typeof (ExifOrientations), meta.GetQuery("/app1/ifd/{ushort=274}").ToString());
        }

        switch (orientation)
        {
          case ExifOrientations.Rotate90:
            angle = -90;
            break;
          case ExifOrientations.Rotate180:
            angle = 180;
            break;
          case ExifOrientations.Rotate270:
            angle = 90;
            break;
        }

        if (angle != 0) //on doit effectuer une rotation de l'image
        {
          ret = new TransformedBitmap(ret.Clone(), new RotateTransform(angle));
          ret.Freeze();
        }
      }
      return ret;
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:33,代码来源:Picture.cs

示例5: Transform

        public static BitmapSource Transform(BitmapSource source, Transform transform)
        {
            if (source == null) throw new ArgumentNullException("source");
            if (transform == null) throw new ArgumentNullException("transform");

            TransformedBitmap target = new TransformedBitmap();
            target.BeginInit();
            target.Source = source;
            target.Transform = transform;
            target.EndInit();
            target.Freeze();

            return CloneImage(target);
        }
开发者ID:ppucik,项目名称:DOZP,代码行数:14,代码来源:ImageFunctions.cs

示例6: VideoDataCallbackDelegate

        // 静态委托
        public void VideoDataCallbackDelegate(int userId, IntPtr buf, int len, AnyChatCoreSDK.BITMAPINFOHEADER bitMap, int userValue)
        {
            int stride = bitMap.biWidth * 3;
            BitmapSource bs = BitmapSource.Create(bitMap.biWidth, bitMap.biHeight, 96, 96, PixelFormats.Bgr24, null, buf, len, stride);
            // 将图像进行翻转
            TransformedBitmap RotateBitmap = new TransformedBitmap();
            RotateBitmap.BeginInit();
            RotateBitmap.Source = bs;
            RotateBitmap.Transform = new RotateTransform(180);
            RotateBitmap.EndInit();
            RotateBitmap.Freeze();

            // 异步操作
            Action action = new Action(delegate()
            {
                Dispatcher.BeginInvoke(new Action(delegate()
                {
                    if (userId == g_selfUserId)
                        localVideoImage.Source = RotateBitmap;
                    else if (userId == g_otherUserId)
                        remoteVideoImage.Source = RotateBitmap;
                }), null);
            });
            action.BeginInvoke(null, null);
        }
开发者ID:dalinhuang,项目名称:presidentproject,代码行数:26,代码来源:Window1.xaml.cs


注:本文中的System.Windows.Media.Imaging.TransformedBitmap.Freeze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。