本文整理汇总了C#中System.Drawing.FastBitmap.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.Clear方法的具体用法?C# FastBitmap.Clear怎么用?C# FastBitmap.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.FastBitmap
的用法示例。
在下文中一共展示了FastBitmap.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClearBitmap
public void TestClearBitmap()
{
Bitmap bitmap = GenerateRandomBitmap(63, 63); // Non-dibisible by 8 bitmap, used to test loop unrolling
FastBitmap.ClearBitmap(bitmap, Color.Red);
// Loop through the image checking the pixels now
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
if (bitmap.GetPixel(x, y).ToArgb() != Color.Red.ToArgb())
{
Assert.Fail(
"Immediately after a call to FastBitmap.Clear(), all of the bitmap's pixels must be of the provided color");
}
}
}
// Test an arbitratry color now
FastBitmap.ClearBitmap(bitmap, Color.FromArgb(25, 12, 0, 42));
// Loop through the image checking the pixels now
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
if (bitmap.GetPixel(x, y).ToArgb() != Color.FromArgb(25, 12, 0, 42).ToArgb())
{
Assert.Fail(
"Immediately after a call to FastBitmap.Clear(), all of the bitmap's pixels must be of the provided color");
}
}
}
// Test instance call
FastBitmap fastBitmap = new FastBitmap(bitmap);
fastBitmap.Clear(Color.FromArgb(25, 12, 0, 42));
Assert.IsFalse(fastBitmap.Locked, "After a successfull call to .Clear() on a fast bitmap previously unlocked, the .Locked property must be false");
// Loop through the image checking the pixels now
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
if (bitmap.GetPixel(x, y).ToArgb() != Color.FromArgb(25, 12, 0, 42).ToArgb())
{
Assert.Fail(
"Immediately after a call to FastBitmap.Clear(), all of the bitmap's pixels must be of the provided color");
}
}
}
}