• Welcome to Valhalla Legends Archive.
 

TGA Icon Extrapolation

Started by Fr3DBr, September 24, 2006, 10:23 PM

Previous topic - Next topic

Joe[x86]

Quote from: Fr3DBr on September 26, 2006, 04:29 AM
actually duh i know how to write files without crlf as i stated i know C#....what i dont know is how to extrapolate each icon from the tga image....

Aren't you brilliant? Of course you know how to write a file using VB, subverting a VB feature, because you know the wonderful all-featured C#. Oh! How foolish of me not to have guessed?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Warrior

Quote from: Joex86] link=topic=15785.msg159043#msg159043 date=1159303659]
Quote from: Fr3DBr on September 26, 2006, 04:29 AM
actually duh i know how to write files without crlf as i stated i know C#....what i dont know is how to extrapolate each icon from the tga image....

Aren't you brilliant? Of course you know how to write a file using VB, subverting a VB feature, because you know the wonderful all-featured C#. Oh! How foolish of me not to have guessed?

Considering using C# is a little harder it'd be pretty silly if he didn't know how, or couldn't pick it up right away.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Fr3DBr

lets dont forget the scope of this thread... the question still remains on what should be done to properly extrapolate the images.

FrostWraith

Dude, seriously. http://bnetdocs.valhallalegends.com/content.php?Section=d&id=3

Also, TGA images are one of the easiest to Read. If I can do it in VB, so can you.

Fr3DBr

man actually i know the document, i just dont know how to separate the TGA DATA i got on my tga file... i have all the icons merged together in one vertical line.... i want to have one file to each icon....

FrostWraith

OK, after each looping of reading images, call this sub:
sry, its VB
Public Sub WriteValues(strData As String, sFilename As String)
Dim nFileNum As Integer

nFileNum = FreeFile

Open sFilename For Binary Lock Read Write As #nFileNum
    Put #nFileNum, , strData
Close #nFileNum

End Sub

Fr3DBr

(DWORD)      Size of BNI header
(WORD)      BNI Version
(WORD)      Alignment Padding (Unused)
(DWORD)      Number of Icons
(DWORD)      Data Offset

For each icon:
   (DWORD)      Flags
   (DWORD)      X Size
   (DWORD)      Y Size
   (DWORD[32])   Products for this icon*

Image in Targa format

Lets discuss about it...

First you parse : 16 Bytes that are the (BNI HEADER) no problem...

Then since you have : 20 Icons You will have to parse 12Bytes + (8Bytes if the Flags are 0 or 4 Bytes if its != than 0) Sure...

Then after all that... you have the TGA Image wich you (SHOULD) separate from all the data you parsed before...
No problem with that i already have the Good Working Targa File that i can see the 20 icons on it in a Vertical Line... (now) how can i have EACH of these icons in one independant file ? Thats what im talking about .... because when looping the First data that tells you wich String Reamins to Wich ICON you dont get anything related to targa format... got me now ?

Thanks.

RealityRipple

wtf is Binary Lock Read Write? that sounds like way too much for just writing data. Try Binary Access Write. In that situation, Lock and Read are useless.

FrostWraith

Meh, just from a tuturial I read. I just never got out of the habit of putting it all there.

Maddox

I wrote this a couple of years ago.  This will take a BNI file, parse it, and let you draw it to a DC.  I hope this helps.

http://www.yousendit.com/transfer.php?action=download&ufid=E3C3E0486D1B28AB
asdf.



l)ragon

'**********************************************
'*         l)ragon,  Dec. 19, 2002            *
'*         TGA Runlength decodeing            *
'**********************************************
Private Sub RLEDecode(ByVal cRead As FileReader)
Dim outBuf As String
Dim BytesToRead As Long
Dim DecodedSize As Long
Dim n As Long
Dim pt As Byte
Dim bufi As Long
Dim tLength As Long
Dim l As Long, b As Long, c As Long, iBul As Long

    BytesToRead = THead.BitsPerPixel / &H8
    DecodedSize = THead.Height * THead.Width * BytesToRead
    While bufi < DecodedSize
        pt = cRead.GetByteAt(l + 1)
        c = 0
        If pt > 127 Then
            n = pt - 127
            For b = 0 To (n - 1)
                For iBul = (l + 2) To ((BytesToRead + (l + 2)) - 1)
                    outBuf = outBuf & Chr$(cRead.GetByteAt(iBul))
                Next
                bufi = bufi + BytesToRead
            Next b
            l = BytesToRead + 1 + l
            n = c + (n * BytesToRead) + 1
        Else
            n = pt + 1
            tLength = n * BytesToRead
            For iBul = (l + 2) To ((tLength + (l + 2)) - 1)
                outBuf = outBuf & Chr$(cRead.GetByteAt(iBul))
            Next
            c = c + tLength
            bufi = bufi + c
            l = (n * BytesToRead + 1) + l
            n = c + n
        End If
    Wend
    Call cRead.SetFileData(outBuf)
End Sub

Feel free to use it, I still think it looks like crap though.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Joe[x86]

Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Mystical

this doesn't look like crap.

Debug.Print "vb6 rocks out with the cock out"

|