本文整理汇总了C#中IEncoder.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IEncoder.GetType方法的具体用法?C# IEncoder.GetType怎么用?C# IEncoder.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEncoder
的用法示例。
在下文中一共展示了IEncoder.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEncoder
private static void TestEncoder(UInt32 imageDimension, IEncoder enc)
{
var i = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
var g = Graphics.FromImage(i);
g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, i.Width, i.Height);
g.DrawEllipse(new Pen(Color.IndianRed), 1, 1, i.Width / 2, i.Height / 2);
g.DrawRectangle(new Pen(Color.GreenYellow, 4), i.Width / 2, i.Width / 2, i.Width / 2 - 4, i.Width / 2 - 4);
var ihdr = new Ihdr(imageDimension, imageDimension, BitDepth._8, ColorType.Rgb);
var apng = new APNG(ihdr);
apng.RegisterDecoder(new SimpleDecoder());
apng.Encoder = enc;
apng.AddDefaultImageFromObject(i);
var frames = new Frame[i.Height / 2];
for(int j = 0; j < i.Height / 2; j++)
{
var bmp = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
var gr = Graphics.FromImage(bmp);
gr.Clear(Color.Blue);
gr.DrawEllipse(new Pen(Color.Lime), bmp.Width / 4, j, bmp.Width / 2, bmp.Height / 2);
frames[j] = new Frame() { Delay = new Rational(10, 100), FrameObject = bmp };
}
apng.SetFrames(frames);
String fileName = String.Format("{0}_{1}x{2}_{3}.png", enc.GetType().Name, imageDimension, imageDimension, 0);
if(File.Exists(fileName))
File.Delete(fileName);
apng.ToFile(fileName);
ihdr = new Ihdr(imageDimension, imageDimension, BitDepth._8, ColorType.Rgb);
apng = new APNG(ihdr);
apng.RegisterDecoder(new SimpleDecoder());
apng.Encoder = enc;
String nowString = DateTime.UtcNow.ToString(@"yyyy\-MM\-dd HH:mm");
g.Clear(Color.Blue);
g.DrawString(nowString, new Font("Consolas", 7), new SolidBrush(Color.Lime), 5, i.Height / 2f);
apng.AddDefaultImageFromObject(i);
frames = new Frame[i.Height / 2-10];
for(int j = 10; j < i.Height / 2; j++)
{
var bmp = new Bitmap((int)imageDimension, (int)imageDimension, PixelFormat.Format24bppRgb);
var gr = Graphics.FromImage(bmp);
gr.Clear(Color.Blue);
gr.DrawString(nowString, new Font("Consolas", 7), new SolidBrush(Color.Lime), 5, j);
frames[j-10] = new Frame() { Delay = new Rational(10, 100), FrameObject = bmp };
}
apng.SetFrames(frames);
fileName = String.Format("{0}_{1}x{2}_{3}.png", enc.GetType().Name, imageDimension, imageDimension, 1);
if(File.Exists(fileName))
File.Delete(fileName);
apng.ToFile(fileName);
}