Convert IMAGE object to STRING for manipulation?

T

Trammel

Hi, I have a vb.net program made to grab screenshots and then store them in
image objects.
The image is displayed in a pictureBox atm but I want to store the data in a
String only.

(Without saving to a file on HDD, then loading it as binary)

Does anyone know how to convert an image into a string & have any pointers
to information on how the image would look when in the string (Like bit
patterns, etc)?
 
J

jcvoon

Hi:

I use the ToBase64String function to convert the image stored in the
database to string;

System.Convert.ToBase64String(CType(dr(i), Byte()))

Hope this help
JCVoon
 
T

Trammel

Code:
imgStr = System.Convert.ToBase64String(CType(img, Byte()))

Returns error:
E:\...\ScreenCapture.vb(88): Value of type 'System.Drawing.Image' cannot be
converted to '1-dimensional array of Byte'.
 
J

jcvoon

Hi:

you need to convert the image to byte array

Dim abyt As Byte()
Dim ms As New IO.MemoryStream
Dim bmp As New Bitmap("yourbitmap.bmp")

bmp.Save(ms, Imaging.ImageFormat.Bmp)

abyt = ms.ToArray()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top