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:
Code:
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)
I'm slightly confused, the code you posted doesn't seem to have alot todo with the situation you described.
Visual Basic:
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]
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.