• Welcome to Valhalla Legends Archive.
 

Converting TGA to BMP/JPG

Started by UserLoser., February 07, 2004, 03:03 PM

Previous topic - Next topic

UserLoser.

Is there any easy way this can be done?  Maybe with DirectX as Grok posted before? (If so, how?)

Any comments/suggestions/examples?

Grok

#1
I thought about this a little more, still haven't tried anything.  Regardless of whether DirectX can do it, you could always render the TGA in a window, then convert the resulting DIB to BMP/JPG.

The window need not be visible.

Mesiah / haiseM

#2
As you know userloser, i was looking into this for a while.

Each 24 bit targa has a header, containing most of the rest of the information you need, but the problem is getting a function to convert the image to a windows recognizable format, other than that, there are tons of ways to display it, imagebox or picturebox if ur lazy, you cain paint it, set urself a device context, then use that in painting the picture (which is done as a DIB, bitmap)

I saw that one function you used to decompress the image, but its in like german, so i dont understand what variables to pass..

Edit: I could try writing my own, but i am extremely poor with mathematical programming, so id prolly never get it working.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

UserLoser.

What I'm looking to do is have an owner drawn listbox (which is already being a pain in the ass to me), and have the icons (icons.bni) drawn for each user..

Grok

I use this library at work.  It supports TGA, and BMP, JPG, etc.  Using it you could convert TGA to DIB and then save the DIB to another format.

http://www.jpg.com/imagxpressview.htm

Adron

Quote from: MesiaH on February 09, 2004, 01:16 AM
As you know userloser, i was looking into this for a while.

Each 24 bit targa has a header, containing most of the rest of the information you need, but the problem is getting a function to convert the image to a windows recognizable format, other than that, there are tons of ways to display it, imagebox or picturebox if ur lazy, you cain paint it, set urself a device context, then use that in painting the picture (which is done as a DIB, bitmap)

I saw that one function you used to decompress the image, but its in like german, so i dont understand what variables to pass..

Edit: I could try writing my own, but i am extremely poor with mathematical programming, so id prolly never get it working.

It's not hard at all. Try it!

Grok

Heh, gogo Blizzard.  Their icons.bni is a broken TGA.  According to the Truevision specification, find out if you have a valid TGA file by inspecting the last 26 bytes of the file.  Bytes 8-23 should be 'TRUEVISION-XFILE'.

Blizzard wrote it to bytes 9-24.  Ugh.  So, Pegasus ImagXpress won't even recognize it.

TheMinistered



Yoni

Quote from: Grok on February 09, 2004, 01:52 PM
Heh, gogo Blizzard.  Their icons.bni is a broken TGA.  According to the Truevision specification, find out if you have a valid TGA file by inspecting the last 26 bytes of the file.  Bytes 8-23 should be 'TRUEVISION-XFILE'.

Blizzard wrote it to bytes 9-24.  Ugh.  So, Pegasus ImagXpress won't even recognize it.
No, Blizzard did it right.
The "bytes 8-23" in the Truevision docs are 0-based, the "bytes 9-24" in your count are 1-based. That's the same thing...
The reason Pegasus couldn't read it is because it's a .bni, not a .tga.
icons.bni is a Blizzard-specific format (bni = Battle.net Icons, probably) that consists of a "BNI header" + a TGA file appended to it.

Here's how to extract the TGA:
1. Open icons.bni in a hex editor.
2. Examine the contents of the 4th dword in the file (bytes 13-16 as a little-endian dword). For example, in
C:\Misc\Battle.net\BinaryChat\icons.bni on my computer, the value is 384.
3. Delete that many bytes from the beginning of the file. (In my case, 384)
4. Save as a .tga and open with anything that reads .tga files.

Grok

What is a BNI header?  I mean, I know its something Blizzard added, but what does it do?  Layout?

Adron

The BNI header defines for what product or for what flags to use each particular icon in the file. There are as many entries as there are icons in the file. IIRC, the entries are one size for product icons and 4 bytes less for flags icons.

Skywing

#12
You could also use IconView to grab the .tga.

UserLoser.

#13
Quote from: Skywing on February 19, 2004, 12:48 AM
You could also use IconView to grab the .tga.

I have that already, but thanks anyways

I can output the entire TGA to a file, but I'm still looking how to split up each image whenever I want to draw one to the listbox

I believe I have some ideas on how to do this - I just don't have the time because this week and probably the next few months will be very busy for me

K

#14
Quote from: UserLoser. on February 19, 2004, 06:13 PM
Quote from: Skywing on February 19, 2004, 12:48 AM
You could also use IconView to grab the .tga.

I have that already, but thanks anyways

I can output the entire TGA to a file, but I'm still looking how to split up each image whenever I want to draw one to the listbox

I believe I have some ideas on how to do this - I just don't have the time because this week and probably the next few months will be very busy for me

IIRC, the BNI header for each product/flag includes the icon width and height - why not split them up into seperate images when you first load the BNI file, then reference those images?  As someone previously mentioned, the task of drawing the TGA onto a surface is not difficult at all.  Simply reference Kane's excellent BNI format page and a TGA format page if required.