Wednesday, December 29, 2004

BmpConverter

A vb.net class to bmpfiles into other image formates. an over loaded version is also used to for the bitmap data in memory stream.

Public Class BmpConverter
Public Function ConvertBMP(ByVal BMPFullPath As String, _
ByVal imgFormat As ImageFormat) As Boolean
Dim boolAns As Boolean
Dim strNewFile As String
Try
'bitmap class in system.drawing.imaging
Dim objBmp As New Bitmap(BMPFullPath)
'below 2 functions in system.io.path
strNewFile = GetDirectoryName(BMPFullPath) & "\" & GetFileNameWithoutExtension(BMPFullPath) & "." & imgFormat.ToString
objBmp.Save(strNewFile, imgFormat)
boolAns = True 'return true on success
Catch
boolAns = False 'return false on error
End Try
Return boolAns
End Function
Public Function ConvertBMP(ByVal strOutpath As String, _
ByVal imgFormat As ImageFormat, _
ByVal ImageStream As MemoryStream) As Boolean
Dim boolAns As Boolean
Dim strNewFile As String
Try
'bitmap class in system.drawing.imaging
Dim mystream As Stream = CType(ImageStream, Stream)
Dim objBmp As New Bitmap(ImageStream)
'below 2 functions in system.io.path
'strNewFile = GetDirectoryName(BMPFullPath) & "\" & GetFileNameWithoutExtension(BMPFullPath) & "." & imgFormat.ToString
objBmp.Save(strOutpath, imgFormat)
boolAns = True 'return true on success
Catch ex As Exception
boolAns = False 'return false on error
End Try
Return boolAns
End Function
End Class

Friday, December 24, 2004

I saw a man who wasn't there

As I was walkin' up the stair
I saw a man who wasn't there

He wasn't there again today
I wish, I wish he'd go away