當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET ImageCodecInfo.GetImageEncoders方法代碼示例

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


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

示例1: GetImageEncodersExample

Public Sub GetImageEncodersExample(ByVal e As PaintEventArgs)

    ' Get an array of available codecs.
    Dim myEncoders() As ImageCodecInfo
    myEncoders = ImageCodecInfo.GetImageEncoders()
    Dim numEncoders As Integer = myEncoders.GetLength(0)
    Dim strNumEncoders As String = numEncoders.ToString()
    Dim foreColor As Color = Color.Black
    Dim font As New Font("Arial", 8)
    Dim i As Integer = 0

    ' Get the info. for all encoders in the array.
    If numEncoders > 0 Then
        Dim myEncoderInfo(numEncoders * 10) As String
        For i = 0 To numEncoders - 1
            myEncoderInfo((i * 10)) = "Codec Name = " _
            + myEncoders(i).CodecName
            myEncoderInfo((i * 10 + 1)) = "Class ID = " _
            + myEncoders(i).Clsid.ToString()
            myEncoderInfo((i * 10 + 2)) = "DLL Name = " _
            + myEncoders(i).DllName
            myEncoderInfo((i * 10 + 3)) = "Filename Ext. = " _
            + myEncoders(i).FilenameExtension
            myEncoderInfo((i * 10 + 4)) = "Flags = " _
            + myEncoders(i).Flags.ToString()
            myEncoderInfo((i * 10 + 5)) = "Format Descrip. = " _
            + myEncoders(i).FormatDescription
            myEncoderInfo((i * 10 + 6)) = "Format ID = " _
            + myEncoders(i).FormatID.ToString()
            myEncoderInfo((i * 10 + 7)) = "MimeType = " _
            + myEncoders(i).MimeType
            myEncoderInfo((i * 10 + 8)) = "Version = " _
            + myEncoders(i).Version.ToString()
            myEncoderInfo((i * 10 + 9)) = " "
        Next i
        Dim numMyEncoderInfo As Integer = myEncoderInfo.GetLength(0)

        ' Render to the screen all the information.
        Dim j As Integer = 20
        For i = 0 To numMyEncoderInfo - 1
            e.Graphics.DrawString(myEncoderInfo(i), font, _
            New SolidBrush(foreColor), 20, j)
            j += 12
        Next i
    Else
        e.Graphics.DrawString("No Encoders Found", font, _
        New SolidBrush(foreColor), 20, 20)
    End If
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Drawing.Imaging,代碼行數:49,代碼來源:ImageCodecInfo.GetImageEncoders

示例2: MainClass

' 導入命名空間
Imports System.Drawing.Imaging
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class MainClass
   public Shared Sub Main
        Dim imgCodecInfo As ImageCodecInfo = Nothing
        Dim curBitmap As New Bitmap("yourfile.jpg")
        Dim j As Integer

        Dim mimeType As String = "image/png"
        Dim encoders() As ImageCodecInfo

        encoders = ImageCodecInfo.GetImageEncoders()

        j = 0
        While j < encoders.Length
            If encoders(j).MimeType = mimeType Then
                imgCodecInfo = encoders(j)
            End If
        End While ' Save as png
        curBitmap.Save("Shape0.png", imgCodecInfo, Nothing)

        curBitmap.Dispose()
   End Sub
End class
開發者ID:VB程序員,項目名稱:System.Drawing.Imaging,代碼行數:28,代碼來源:ImageCodecInfo.GetImageEncoders


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