Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Well, i figured out how to convert a bitmap into a byte array. I use this to save signatures from a pocket pc emulator.

 

How would I convert the byte array back to a bitmap to display what i had previously saved.

I found something like this on the internet:

Dim BackGroundImage As Bitmap
Dim ImageFileName As String = "path"

BackGroundImage = New Bitmap(ImageFileName)
GraphicsHandle = Graphics.FromImage(BackGroundImage)

but that doesn't seem to be working. i get an "Exception" error on BackGroundImage = New bitmap(imagefilename)

 

Any thoughts??

Posted

I'm slightly confused, the code you posted doesn't seem to have alot todo with the situation you described.

BackGroundImage = New Bitmap(ImageFileName)

Basically this line of code is designed to load a Bitmap file into your application. The ImageFileName field would contain the path of a Bitmap for example "c:\myImage.bmp". If you pass this overload a path to a valid Image I see no reason why it wouldn't work correctly. What you described however was creating a bitmap object from a Byte array, is this what you want todo? Because it isn't quite as simple as this. It's a while since I've loaded a bitmap from a byte array, but if you can clarify this is what you wish todo, I can try and rustle up an example.

[edit]Just to send you in the right direction, I believe the best approach is to read the byte array into a stream as the Bitmap class has a constuctor overload that supports streams.[/edit]

Anybody looking for a graduate programmer (Midlands, England)?
Posted

Sorry for the confusion but you're right that does work. My problem was the path wasn't correctly stated.

 

Thanks.

 

 

and by the way, i was looking for an alternative way to display the bitmap since i couldn't get:

BackGroundImage = New Bitmap(ImageFileName)

to work correctly and i had been tyring to find my problem for two days now.

its funny how the smallest things are always overlooked.

 

thanks again.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...