code Mechanic
Member
Hi Folks,
I have written a custom graph control, I want to be able to allow users to export an image of the control to disk in several formats. The only fomat that looks ok is ".png" files. The others have a black back ground and all the other colours are screwed.
Heres the code:
Public Sub ExportImage(ByVal strFileName As String)
Dim MyImage As Bitmap = New Bitmap(Me.Width, Me.Height)
Dim Gfx As Graphics = Graphics.FromImage(MyImage)
DrawGraph(Gfx)
DrawPoints(Gfx)
DrawCurve(Gfx)
Select Case GetFileExtension(strFileName).ToLower
Case "bmp"
MyImage.Save(strFileName, ImageFormat.Bmp)
Case "jpg"
MyImage.Save(strFileName, ImageFormat.Jpeg)
Case "gif"
MyImage.Save(strFileName, ImageFormat.Gif)
Case "png"
MyImage.Save(strFileName, ImageFormat.Png)
End Select
Gfx.Dispose()
End Sub
Any ideas on how to correct this?
Thanks in advance.
CM
I have written a custom graph control, I want to be able to allow users to export an image of the control to disk in several formats. The only fomat that looks ok is ".png" files. The others have a black back ground and all the other colours are screwed.
Heres the code:
Public Sub ExportImage(ByVal strFileName As String)
Dim MyImage As Bitmap = New Bitmap(Me.Width, Me.Height)
Dim Gfx As Graphics = Graphics.FromImage(MyImage)
DrawGraph(Gfx)
DrawPoints(Gfx)
DrawCurve(Gfx)
Select Case GetFileExtension(strFileName).ToLower
Case "bmp"
MyImage.Save(strFileName, ImageFormat.Bmp)
Case "jpg"
MyImage.Save(strFileName, ImageFormat.Jpeg)
Case "gif"
MyImage.Save(strFileName, ImageFormat.Gif)
Case "png"
MyImage.Save(strFileName, ImageFormat.Png)
End Select
Gfx.Dispose()
End Sub
Any ideas on how to correct this?
Thanks in advance.
CM