VB.Net Tutorial/2D Graphics/PNG
Версия от 16:40, 26 мая 2010; (обсуждение)
Convert jpeg to png
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
PNG Encoder
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Imaging
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
curBitmap.Save("yourfile.png", imgCodecInfo, Nothing)
curBitmap.Dispose()
End Sub
End class