本文整理匯總了C#中System.Image.View方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.View方法的具體用法?C# Image.View怎麽用?C# Image.View使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Image
的用法示例。
在下文中一共展示了Image.View方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ImageView_IsSolid
public void ImageView_IsSolid()
{
Image i = new Image(256, 256);
ImageView iv = i.View(0, 0, 256, 256);
Assert.IsTrue(iv.IsSolid());
i.SetPixel(0, 0, new Color("red"));
iv = i.View(0, 0, 256, 256);
Assert.IsFalse(iv.IsSolid());
}
示例2: ImageView_Init
public void ImageView_Init()
{
Map m = new Map(256, 256);
Image i = new Image(256, 256);
ImageView iv = i.View(0, 0, 256, 256);
Assert.IsTrue(iv.IsSolid());
Color pixel = iv.GetPixel(0, 0);
Assert.AreEqual(pixel.ToString(), "rgba(0,0,0,0.0)");
m.Background = new Color(255, 255, 255);
m.Render(i);
iv = i.View(0, 0, 256, 256);
Assert.IsTrue(iv.IsSolid());
pixel = iv.GetPixel(0, 0);
Assert.AreEqual(pixel.ToString(), "rgb(255,255,255)");
}
示例3: ImageView_Encode
public void ImageView_Encode()
{
Map m = new Map(100, 100);
Image i = new Image(100, 100);
m.Background = new Color("green");
m.Render(i);
ImageView iv = i.View(0, 0, 10, 10);
byte[] bytes1 = iv.Encode("png");
byte[] bytes2 = File.ReadAllBytes(@".\data\10x10green.png");
CollectionAssert.AreEqual(bytes1, bytes2);
}
示例4: ImageView_Save
public void ImageView_Save()
{
Map m = new Map(100, 100);
Image i = new Image(100, 100);
m.Background = new Color("green");
m.Render(i);
ImageView iv = i.View(0,0,10,10);
string filename = @".\data\tmp\" + Guid.NewGuid().ToString() + ".png";
iv.Save(filename);
byte[] bytes1 = File.ReadAllBytes(filename);
byte[] bytes2 = File.ReadAllBytes(@".\data\10x10green.png");
CollectionAssert.AreEqual(bytes1, bytes2);
}