|
-
Aug 25th, 2005, 10:42 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] image field type to string and vice versa
hi,
I have a field type image im my MS sql table. It is posible to convert this field to string and later back again to image for viewing. Pls help me. Im stuck for this work.
pls help me.
popskie
-
Aug 25th, 2005, 11:33 PM
#2
Re: image field type to string and vice versa
IMAGE TO STRING?
you're definetly doing something very very wrong.
while it may be possible, it would take up a huge amount of space and it would be stupid. why do you want it to be converted to string?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Aug 25th, 2005, 11:42 PM
#3
Thread Starter
Fanatic Member
Re: image field type to string and vice versa
ok explain it to u. I have a field type which is image. When user user retreive data, the field image is save as string to the listview sub item. then if the user click it will convert string to byte[] in order to veiw the image . I have a code and a class below but there is error invalid paramer used.
// code
strtobyte cl = new strtobyte();
byte[] photo = null;
photo = cl.StrToByteArray(listView1.SelectedItems[0].SubItems[14].ToString()
System.IO.Stream mystream = new System.IO.MemoryStream(photo, true);
mystream.Write(photo, 0, photo.Length);
id.Image = new Bitmap(mystream);
// class
public class strtobyte
{
public byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
public string ByteArraytostr(byte[] Bytes)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetString(Bytes);
}
}
Last edited by popskie; Aug 25th, 2005 at 11:46 PM.
-
Aug 26th, 2005, 12:08 AM
#4
Re: image field type to string and vice versa
I'm not sure why it wouldnt work, it might be because of ascii
still you should not need to do that. Are you aware that each listView item has a property called "Tag" where you can assign anything to it. Instead of adding the image to the list item's subitem, set the listitem's tag property to it.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Aug 26th, 2005, 12:11 AM
#5
Re: image field type to string and vice versa
There doesn't seem to be any useful purpose to displaying the image as a string. It would be complete gibberish anyway.
On another note, 90 posts is enough to be familiar with the [code] tags. Please use them to make your code more readable. Also, if you are getting an unhandled exception please specify where exactly it is thrown. We're trying to help you so please don't make us guess.
-
Aug 26th, 2005, 12:35 AM
#6
Thread Starter
Fanatic Member
Re: image field type to string and vice versa
MrPolite thanks for your great idea it really really works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|