C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Convert Bitmap to Another Image Format


Posted Date: 14 May 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: Rekha Member Level: Gold    
Rating: Points: 10



Converts a bitmap file to another format which you specify. The new file is saved in the same folder with the same file name, with the appropriate extension (e.g., C:\a.bmp is saved as C:\aa.gif)

Declare this
Imports System.IO.Path
Imports System.Drawing.Imaging

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)




Responses

Author: Vasudevan Deepak Kumar    14 May 2008Member Level: Diamond   Points : 2
A few days back I have shared a similar topic on System.Drawing.Imaging API here:

http://www.dotnetspider.com/resources/3020-Quick-Effective-Tips-Image-API-Input-Validat.aspx


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to update a database from a DataSet object by using Visual Basic .NET
Previous Resource: Running application from another system
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use