本文整理汇总了C#中PixelFormat.GetPixelSize方法的典型用法代码示例。如果您正苦于以下问题:C# PixelFormat.GetPixelSize方法的具体用法?C# PixelFormat.GetPixelSize怎么用?C# PixelFormat.GetPixelSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelFormat
的用法示例。
在下文中一共展示了PixelFormat.GetPixelSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decompress
/// <summary>
/// Decompress a JPEG image to an RGB or grayscale image.
/// </summary>
/// <returns>A byte buffer containing the decompressed image.</returns>
/// <param name="jpegBuf">A buffer containing the JPEG image to decompress.</param>
/// <param name="pixelFormat">Desired pixel format of the destination image.</param>
/// <param name="bottomUp">If true, then the uncompressed result should be stored in bottom-up (Windows, OpenGL) order, not top-down (X11) order.</param>
public byte[] Decompress(byte[] jpegBuf, PixelFormat pixelFormat = PixelFormat.RGB, bool bottomUp = false)
{
if (jpegBuf == null)
throw new ArgumentNullException(nameof (jpegBuf));
ChrominanceSubsampling subsamp;
Colorspace colorspace;
int width, height;
DecompressHeader(jpegBuf, out width, out height, out subsamp, out colorspace);
int pitch = pixelFormat.GetPixelSize() * width;
byte[] dstBuf = new byte[pitch * height];
FunctionFlags flags = FunctionFlags.NoRealloc;
if (bottomUp)
flags |= FunctionFlags.BottomUp;
Library.tjDecompress2(_handle, jpegBuf, dstBuf, width, pitch, height, pixelFormat, flags);
return dstBuf;
}