Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert hex string to file/bitmap?

Status
Not open for further replies.

NipsMG

Programmer
Dec 27, 2000
215
US
I've got a library (tagnetlib) that i'm using to grab id3v2 information from an MP3 File. I'm specifically having trouble with embedded image information.

I'm able to extract the data, which is in the following format:

Size)HexStringGoesHere+.
FrameName[Type,Enclding, MimeType, ?, ?, Data]

An Example:
APIC[Pic,ASCII,'image/jpg',Other,'',(9369)ffd8ffe000104a46494600010101012c012c0000f
fdb004300080606070605080707070909080a0c140d0
c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720+]

The last field is the data. (Note: I wrapped the line
twice. All the hex data should be concatenated into one
long string.)

It's in the format:
(Size)DataInHex+

I need to decode this into image information. I'd prefer to put it into some kind of stream (MemoryStream, etc) and create a Bitmap object on the fly and pass it to an image box. if I have to save it as JPEG first in a temp file before loading, so be it.

The example given in ACTUAL DATA. It should display an album cover by the band Chevelle, for their album "Wonder What's Next". So you can actually test suggested code before submitting if you'd like.

Thanks in advance for anyone that can help.
 
do a google search for something along the lines of saving binary data to XML, and vice versa.

I did something like this not too long ago, needed to store an image in an xml file, so i converted it to base64, which would be the only difference from what you are trying to do, just use the hex funtion instead of base64. Basically you'll convert the hex into a byte array, then dump that into a stream object, somewhere along the way you can specify the format (jpg/gif/png,etc)

If i look around I might be able to dig up the code..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top