當前位置: 首頁>>代碼示例>>C#>>正文


C# ImageCodecInfo.GetImageEncoders方法代碼示例

本文整理匯總了C#中System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders方法的典型用法代碼示例。如果您正苦於以下問題:C# ImageCodecInfo.GetImageEncoders方法的具體用法?C# ImageCodecInfo.GetImageEncoders怎麽用?C# ImageCodecInfo.GetImageEncoders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了ImageCodecInfo.GetImageEncoders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetImageEncodersExample

private void GetImageEncodersExample(PaintEventArgs e)
{
             
    // Get an array of available codecs.
    ImageCodecInfo[] myCodecs;
    myCodecs = ImageCodecInfo.GetImageEncoders();
    int numCodecs = myCodecs.GetLength(0);
             
    //numCodecs = 1;
             
    // Set up display variables.
    Color foreColor = Color.Black;
    Font font = new Font("Arial", 8);
    int i = 0;
             
    // Check to determine whether any codecs were found.
    if(numCodecs > 0)
    {
             
        // Set up an array to hold codec information. There are 9
             
        // information elements plus 1 space for each codec, so 10 times
             
        // the number of codecs found is allocated.
        string[] myCodecInfo = new string[numCodecs*10];
             
        // Write all the codec information to the array.
        for(i=0;i<numCodecs;i++)
        {
            myCodecInfo[i*10] = "Codec Name = " + myCodecs[i].CodecName;
            myCodecInfo[(i*10)+1] = "Class ID = " +
                myCodecs[i].Clsid.ToString();
            myCodecInfo[(i*10)+2] = "DLL Name = " + myCodecs[i].DllName;
            myCodecInfo[(i*10)+3] = "Filename Ext. = " +
                myCodecs[i].FilenameExtension;
            myCodecInfo[(i*10)+4] = "Flags = " +
                myCodecs[i].Flags.ToString();
            myCodecInfo[(i*10)+5] = "Format Descrip. = " +
                myCodecs[i].FormatDescription;
            myCodecInfo[(i*10)+6] = "Format ID = " +
                myCodecs[i].FormatID.ToString();
            myCodecInfo[(i*10)+7] = "MimeType = " + myCodecs[i].MimeType;
            myCodecInfo[(i*10)+8] = "Version = " +
                myCodecs[i].Version.ToString();
            myCodecInfo[(i*10)+9] = " ";
        }
        int numMyCodecInfo = myCodecInfo.GetLength(0);
             
        // Render all of the information to the screen.
        int j=20;
        for(i=0;i<numMyCodecInfo;i++)
        {
            e.Graphics.DrawString(myCodecInfo[i],
                font,
                new SolidBrush(foreColor),
                20,
                j);
            j+=12;
        }
    }
    else
        e.Graphics.DrawString("No Codecs Found",
            font,
            new SolidBrush(foreColor),
            20,
            20);
}
開發者ID:.NET開發者,項目名稱:System.Drawing.Imaging,代碼行數:67,代碼來源:ImageCodecInfo.GetImageEncoders

示例2: Main

//引入命名空間
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;

public class MainClass {

    public static void Main() {
    ImageCodecInfo[] availableCodecs;
    availableCodecs = ImageCodecInfo.GetImageEncoders();
    int numCodecs = availableCodecs.Length;

    for (int i = 0; i < numCodecs; i++)
    {
      Console.WriteLine("Codec Name = " + availableCodecs[i].CodecName);
      Console.WriteLine("Class ID = " + availableCodecs[i].Clsid.ToString());
      Console.WriteLine("Filename Extension = " +
        availableCodecs[i].FilenameExtension);
      Console.WriteLine("Flags = " +
        availableCodecs[i].Flags.ToString());
      Console.WriteLine("Format Description = " +
        availableCodecs[i].FormatDescription);
      Console.WriteLine("Format ID = " +
        availableCodecs[i].FormatID.ToString());
      Console.WriteLine("MimeType = " + availableCodecs[i].MimeType);
      Console.WriteLine("Version = " +
        availableCodecs[i].Version.ToString());
      Console.WriteLine();
    }
    }
}
開發者ID:C#程序員,項目名稱:System.Drawing.Imaging,代碼行數:36,代碼來源:ImageCodecInfo.GetImageEncoders


注:本文中的System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。