jpbivona
asked on
Visual Studio 2005 - VB - System.Drawing - FromStream() method not available
I am trying to use the following line of code in Visual Studio 2005:
Imports System.IO
Imports System.Drawing
Sub Base64Convert(ByVal Base64MSG As String, ByRef ID As String, ByRef FName As String, ByRef LName As String)
'Setup image and get data stream together
Dim img As System.Drawing.Image
Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream
Dim b64 As String = Base64MSG
Dim b() As Byte
'Converts the base64 encoded msg to image data
b = Convert.FromBase64String(b 64)
MS = New System.IO.MemoryStream(b)
'creates image
img = System.Drawing.Image.FromS tream(MS)
'writes image for displaying
img.Save(Path.GetDirectory Name(Syste m.Reflecti on.Assembl y.GetExecu tingAssemb ly().GetNa me().CodeB ase) & "sig_" & ID & "_" & FName & "_" & LName & ".bmp", System.Drawing.Imaging.Ima geFormat.B mp)
'cleaning up house
img.Dispose()
MS.Close()
End Sub
This line: img = System.Drawing.Image.FromS tream(MS)
presents a syntax error saying 'FromStream is not a member of System.Drawing.Image'
When VS 2005 attempts to autocomplete as I type: System.Drawing.Image.
It only presents 3 choice, which are: Equals, FromHBitMap, and ReferenceEquals
Does anyone have any idea what is going on here?
Thanks much.
Imports System.IO
Imports System.Drawing
Sub Base64Convert(ByVal Base64MSG As String, ByRef ID As String, ByRef FName As String, ByRef LName As String)
'Setup image and get data stream together
Dim img As System.Drawing.Image
Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream
Dim b64 As String = Base64MSG
Dim b() As Byte
'Converts the base64 encoded msg to image data
b = Convert.FromBase64String(b
MS = New System.IO.MemoryStream(b)
'creates image
img = System.Drawing.Image.FromS
'writes image for displaying
img.Save(Path.GetDirectory
'cleaning up house
img.Dispose()
MS.Close()
End Sub
This line: img = System.Drawing.Image.FromS
presents a syntax error saying 'FromStream is not a member of System.Drawing.Image'
When VS 2005 attempts to autocomplete as I type: System.Drawing.Image.
It only presents 3 choice, which are: Equals, FromHBitMap, and ReferenceEquals
Does anyone have any idea what is going on here?
Thanks much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I do have System.Drawing Version 2.0.0.0 Reference. I teied to remove and re-add, but didn't have an effect. You asked about .Net CF, is this the compact framework? I am using it I think, this code is for a mobile device application. Does this have any consequence?
ASKER
Or, how can I modify my code above to use the FromHBitMap Method?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Think of CF as a stripped down version.
Check this link out about FromHBitMap
http://www.velocityreviews.com/forums/t77332-dynamic-images.html
I hope this helps. I've never used FromHBitMap myself.
Check this link out about FromHBitMap
http://www.velocityreviews.com/forums/t77332-dynamic-images.html
I hope this helps. I've never used FromHBitMap myself.
ASKER
Ok, I will.
But what do I use to create a .bmp file from a hex text file in VB?
But what do I use to create a .bmp file from a hex text file in VB?
Try
img = BitMap(MS)
BitMap(stream) is supported by CF
http://msdn2.microsoft.com/en-us/library/z7ha67kw.aspx
img = BitMap(MS)
BitMap(stream) is supported by CF
http://msdn2.microsoft.com/en-us/library/z7ha67kw.aspx
Project -> {Project Name} Properties -> References Tab
Then re-add the reference via:
Project -> Add References
If it still does it try creating a new VB project and doing the same to see wether its a problem with Visual Studio or in the App that your writing.