|
|
|
|
|
Dicas
|
|
Visual Basic.Net (Imagem/Som/Multimídia)
|
|
|
Título da Dica: Converter BMP para outro formato
|
|
|
|
Postada em 9/10/2003 por Roßerto
Declarations:
Imports System.IO.Path Imports System.Drawing.Imaging
Codigo: Public Function ConvertBMP(ByVal BMPFullPath As String, _ ByVal imgFormat As ImageFormat) As Boolean
Dim bAns As Boolean Dim sNewFile As String
Try 'bitmap class in system.drawing.imaging Dim objBmp As New Bitmap(BMPFullPath)
'below 2 functions in system.io.path sNewFile = GetDirectoryName(BMPFullPath) sNewFile &= GetFileNameWithoutExtension(BMPFullPath)
sNewFile &= "." & imgFormat.ToString objBmp.Save(sNewFile, imgFormat)
bAns = True 'return true on success Catch bAns = False 'return false on error End Try Return bAns
End Function 'USAGE 'ConvertBMP("C:\test.bmp", ImageFormat.Jpeg) 'ConvertBMP("C:\test.bmp", ImageFormat.Emf) 'ConvertBMP("C:\test.bmp", ImageFormat.Exif) 'ConvertBMP("C:\test.bmp", ImageFormat.Gif) 'ConvertBMP("C:\test.bmp", ImageFormat.Icon) 'ConvertBMP("C:\test.bmp", ImageFormat.MemoryBmp) 'ConvertBMP("C:\test.bmp", ImageFormat.Png) 'ConvertBMP("C:\test.bmp", ImageFormat.Tiff) 'ConvertBMP("C:\test.bmp", ImageFormat.Wmf)
|
|
|
|
|