本文整理匯總了C#中System.Windows.Media.Imaging.BitmapSource.CriticalCopyPixels方法的典型用法代碼示例。如果您正苦於以下問題:C# BitmapSource.CriticalCopyPixels方法的具體用法?C# BitmapSource.CriticalCopyPixels怎麽用?C# BitmapSource.CriticalCopyPixels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Media.Imaging.BitmapSource
的用法示例。
在下文中一共展示了BitmapSource.CriticalCopyPixels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InitFromBitmapSource
private void InitFromBitmapSource(
BitmapSource source
)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (source.PixelWidth < 0)
{
// Backwards Compat
HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
}
if (source.PixelHeight < 0)
{
// Backwards Compat
HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW);
}
BeginInit();
_syncObject = source.SyncObject;
lock (_syncObject)
{
Guid formatGuid = source.Format.Guid;
SafeMILHandle internalPalette = new SafeMILHandle();
if (source.Format.Palettized)
{
internalPalette = source.Palette.InternalPalette;
}
HRESULT.Check(MILSwDoubleBufferedBitmap.Create(
(uint)source.PixelWidth, // safe cast
(uint)source.PixelHeight, // safe cast
source.DpiX,
source.DpiY,
ref formatGuid,
internalPalette,
out _pDoubleBufferedBitmap
));
_pDoubleBufferedBitmap.UpdateEstimatedSize(
GetEstimatedSize(source.PixelWidth, source.PixelHeight, source.Format));
Lock();
Int32Rect rcFull = new Int32Rect(0, 0, _pixelWidth, _pixelHeight);
int bufferSize = checked(_backBufferStride.Value * source.PixelHeight);
source.CriticalCopyPixels(rcFull, _backBuffer, bufferSize, _backBufferStride.Value);
AddDirtyRect(rcFull);
Unlock();
}
EndInit();
}