本文整理匯總了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");
}
}
}
}