本文整理汇总了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()
};
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}