Link to home
Start Free TrialLog in
Avatar of jpbivona
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(b64)
     MS = New System.IO.MemoryStream(b)

   'creates image
    img = System.Drawing.Image.FromStream(MS)

   'writes image for displaying
   img.Save(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "sig_" & ID & "_" & FName & "_" & LName & ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
   'cleaning up house
   img.Dispose()
   MS.Close()
   End Sub

This line: img = System.Drawing.Image.FromStream(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.
Avatar of microbolt
microbolt

Thats a new error for me, hanvn't seen that ever happen.  Could try to remove and rereference the System.Drawing Namespace.  Can remove the reference this way:

             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.
ASKER CERTIFIED SOLUTION
Avatar of billycotx
billycotx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jpbivona

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?
Or, how can I modify my code above to use the FromHBitMap Method?
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Ok, I will.

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