本文整理汇总了C#中PixelFormat.GetColorCount方法的典型用法代码示例。如果您正苦于以下问题:C# PixelFormat.GetColorCount方法的具体用法?C# PixelFormat.GetColorCount怎么用?C# PixelFormat.GetColorCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelFormat
的用法示例。
在下文中一共展示了PixelFormat.GetColorCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bitmap
public Bitmap(int width, int height, int stride, PixelFormat pixelFormat, IntPtr scan0)
{
_width = width;
_height = height;
_stride = stride;
_pixelFormat = pixelFormat;
_scan0 = scan0;
_freeScan0 = false;
if (pixelFormat.IsIndexed())
Palette = new ColorPalette(new Color[pixelFormat.GetColorCount()]);
}
示例2: Clone
public Bitmap Clone(PixelFormat pixelFormat)
{
List<Color> palette = null;
// indexed formats require 2 passes - one more pass to determines colors for palette beforehand
if (pixelFormat.IsIndexed())
{
Quantizer.Prepare(this);
// Pass: scan
ImageBuffer.ProcessPerPixel(this, null, 4, (passIndex, pixel) =>
{
var color = pixel.GetColor();
Quantizer.AddColor(color, pixel.X, pixel.Y);
return true;
});
// determines palette
palette = Quantizer.GetPalette(pixelFormat.GetColorCount());
}
// Pass: apply
Image result;
ImageBuffer.TransformImagePerPixel(this, pixelFormat, palette, out result, null, 4, (passIndex, sourcePixel, targetPixel) =>
{
var color = sourcePixel.GetColor();
targetPixel.SetColor(color, Quantizer);
return true;
});
return (Bitmap)result;
}
示例3: Clone
public Bitmap Clone(PixelFormat pixelFormat)
{
if (pixelFormat == this._pixelFormat)
{
return new Bitmap(this);
}
List<Color> palette = null;
// indexed formats require 2 passes - one more pass to determines colors for palette beforehand
if (pixelFormat.IsIndexed())
{
var quantizer = new DistinctSelectionQuantizer();
quantizer.Prepare(this);
// Pass: scan
ImageBuffer.ProcessPerPixel(this, null, ParallelTaskCount, (passIndex, pixel) =>
{
var color = pixel.GetColor();
quantizer.AddColor(color, pixel.X, pixel.Y);
return false;
});
// determines palette
palette = quantizer.GetPalette(pixelFormat.GetColorCount());
}
// Pass: apply
Image result;
ImageBuffer.TransformImagePerPixel(this, pixelFormat, palette, out result, null, ParallelTaskCount,
(passIndex, sourcePixel, targetPixel) =>
{
var color = sourcePixel.GetColor();
targetPixel.SetColor(color, _quantizer);
return true;
});
return (Bitmap)result;
}