一个BitmapFrame和BitmapImage的WPF中之间的区别区别、BitmapFrame、BitmapImage、WPF

由网友(低丅頭吻伱)分享简介:一个BitmapFrame和BitmapImage的WPF中之间的区别是什么?你会在哪里使用每个(即为什么要使用BitmapFrame而不是BitmapImage的?)What is the difference between a BitmapFrame and BitmapImage in WPF? Where...

一个BitmapFrame和BitmapImage的WPF中之间的区别是什么?你会在哪里使用每个(即为什么要使用BitmapFrame而不是BitmapImage的?)

What is the difference between a BitmapFrame and BitmapImage in WPF? Where would you use each (ie. why would you use a BitmapFrame rather than a BitmapImage?)

推荐答案

您应该坚持使用抽象类BitmapSource如果你需要获取位,甚至的ImageSource 如果你只是想画它。

You should stick to using the abstract class BitmapSource if you need to get at the bits, or even ImageSource if you just want to draw it.

的实施BitmapFrame是实施只是面向对象的性质显示通过。你真的不应该有任何需要的实现之间的区别。 BitmapFrames可能包含一些额外信息(元数据),但通常不过是一种成像应用程序会关心。

The implementation BitmapFrame is just the object oriented nature of the implementation showing through. You shouldn't really have any need to distinguish between the implementations. BitmapFrames may contain a little extra information (metadata), but usually nothing but an imaging app would care about.

您会发现,从的BitmapSource继承这些其他类:

You'll notice these other classes that inherit from BitmapSource:

BitmapFrame 的BitmapImage CachedBitmap Col​​orConvertedBitmap CroppedBitmap FormatConvertedBitmap RenderTargetBitmap TransformedBitmap WriteableBitmap的

您可以通过构造的BitmapImage对象从一个URI一个的BitmapSource:

You can get a BitmapSource from a URI by constructing a BitmapImage object:

Uri uri = ...;
BitmapSource bmp = new BitmapImage(uri);
Console.WriteLine("{0}x{1}", bmp.PixelWIdth, bmp.PixelHeight);

本的BitmapSource也可能来自德codeR。在这种情况下,你是间接使用BitmapFrames。

The BitmapSource could also come from a decoder. In this case you are indirectly using BitmapFrames.

Uri uri = ...;
BitmapDecoder dec = BitmapDecoder.Create(uri, BitmapCreateOptions.None, BitmapCacheOption.Default);
BitmapSource bmp = dec.Frames[0];
Console.WriteLine("{0}x{1}", bmp.PixelWIdth, bmp.PixelHeight);
阅读全文

相关推荐

最新文章