Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Unheadered (?) TGA and BMP

Featured Replies

  • Author
  • Localization

lupus, posted Thu Dec 07, 2017 5:00 pm (30566)


Hi after unpacking Jungle Storm data (NNG) I have many TGA and BMP pics, but seems it all unheadered.
So, I can see some "image" opening TGA with hex editor. Also I try paste header to BMP from other image and can see some data with i_wiev bat it not correct.
Is it possible to restore headers or convert images for editing?
Samples and executable here:
https://mega.nz/#!5lNRGDja!VkOkvAH8UCbG ... xjLvSzOkX0
Upd
Also i can see some gfx with texture finder.
  • Author
  • Localization

episoder, posted Thu Dec 07, 2017 9:42 pm (30569)


if you got texture finder you can work with it. all the files have the sizes in the broken headers. the ai_somethings are a plain 16-bit rgb. most others have 32-bit palettes with a 8-bit index format (256 colors).

Code:
header_tga
{
   int32   dummy;
   int32   width;
   int32   height;
   int32   nr_pal_entries;
   int32   unk0;
   int32   unk1;
}

then palette

then index bitmap


the bmp have this lil header. a 16-bit palette and 8-bit index format (256 colors).

Code:
header_bmp
{
   byte   unk0;
   int32   width;
   int32   height;
}

then palette

then index bitmap


i gotta write bmses? maybe acewell does again. :)
  • Author
  • Localization

lupus, posted Fri Dec 08, 2017 5:07 am (30573)


Thx! bms script will be great!
  • Author
  • Localization

Acewell, posted Thu Dec 21, 2017 2:52 pm (30945)


i guess episoder isn't coming back :P
i don't usually deal with palleted images but i figured i'd play around with these for some experience :)
here is a Noesis python script to at least open the tga and bmp samples which i think look ok now. :D
*script updated December 24, 2017*


i looked up "Jungle Storm" and got a hit with "Ghost Recon: Jungle Storm" 2004,
so i labeled the script after that game, and i assume the samples are from "N-Gage" judging by your signature. :)

tex_GhostReconJungleStorm_NGage_tga_bmp.zip

  • Author
  • Localization

lupus, posted Thu Dec 21, 2017 4:53 pm (30949)


Acewell Oh, thanks man, I'm almost lose the hope! Looks like it works fine with many tga from Ghost Recon but bmp...
Also, I found another gameloft game Splinter Cell Chaos Theory. Looks like it uses similar unheadered tga and bmp, but Noesis can't show it :/

Can I upload samples and pm it to you?
  • Author
  • Localization

episoder, posted Thu Dec 21, 2017 10:20 pm (30951)


ohh. sorry i took detours. i got some behemoth thing i'm trying to do.

nonetheless... i played with those bmps a lil bit just now. it doesn't make a lot of sense. endianness fails. standard palette formats fail. and...

the index map could still be used as a sorta brightness map gimmick. i just... didn't get the obvious thing.

Image

a good morning coffee later :D

nvm: me editing

*snip*

that was code for the rgb4 palette and stuff...
  • Author
  • Localization

Acewell, posted Fri Dec 22, 2017 2:47 am (30956)


lupus wrote:
Also, I found another gameloft game Splinter Cell Chaos Theory. Looks like it uses similar unheadered tga and bmp, but Noesis can't show it :/
Can I upload samples and pm it to you?

better if you make a new thread for each game and link samples there, but like i already said,
i don't usually deal with paletted textures and i also don't deal with or discuss research in private,
i believe in open research to share with everyone. :)
  • Author
  • Localization

episoder, posted Fri Dec 22, 2017 9:37 am (30964)


Acewell wrote:
i believe in open research to share with everyone. :)

you too? me too. pretty strict 'no private requests' rule.

well... now... it seems to work. reads the bmps as rgbx4 palette with alpha key index. cpt. obvious failure. :mrgreen:

Code:
log MEMORY_FILE1 0 0 ; out
log MEMORY_FILE2 0 0 ; tpal

goto 1 0
get width long 0
get height long 0
get nr_pals short 0
get alphakey byte 0
get shortcut byte 0

for p = 1 to nr_pals
get pal short
set r pal
math r >> 4
math r & 0xF0
set g pal
math g >> 0
math g & 0xF0
set b pal
math b math b & 0xF0
put b byte MEMORY_FILE2
put g byte MEMORY_FILE2
put r byte MEMORY_FILE2
put 0xFF byte MEMORY_FILE2 ; alpha is not present but always opaque
next p

xmath ofs_pal "alphakey * 4 3"
goto ofs_pal MEMORY_FILE2
put 0 byte MEMORY_FILE2 ; not opaque

put 0 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 2 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 0 byte MEMORY_FILE1
put 0 short MEMORY_FILE1
put 0 short MEMORY_FILE1
put width short MEMORY_FILE1
put height short MEMORY_FILE1
put 32 byte MEMORY_FILE1
put 0x20 byte MEMORY_FILE1

for y = 1 to height
for x = 1 to width
get px byte 0

math ofs_pal = px
math ofs_pal *= 4
goto ofs_pal MEMORY_FILE2
get rgba long MEMORY_FILE2
put rgba long MEMORY_FILE1

next x
next y

get buffer ASIZE MEMORY_FILE1
get name FILENAME 0
string name -= 4
string name = .tga
log name 0 buffer MEMORY_FILE1


edit: redone. should be easier portable to noesis, if you get to set the alpha 0 in that only palette entry.
  • Author
  • Localization

Acewell, posted Mon Dec 25, 2017 4:45 am (31005)


awesome :D thanks to your script i was able to translate the meat and potatoes to my Noesis python script. :D
so i updated the previous script here to open open those tga and bmp samples :)
viewtopic.php?p=30945#p30945
  • Author
  • Localization

episoder, posted Mon Dec 25, 2017 1:46 pm (31014)


interesting. doesn't wanna download. 0 byte file. and i thought i could learn some noesis stuff. not then.

bug hunt: does the forums break updated file attachements with identical names?
  • Author
  • Localization

Acewell, posted Mon Dec 25, 2017 4:05 pm (31019)


hmm thats strange, i just downloaded the attachment 3 times in a row and they all worked, maybe try again. :)

i am beginning to take some interest in paletted textures now that i have a better understanding
of them thanks to the scripts you share. :D
  • Author
  • Localization

episoder, posted Sat Dec 30, 2017 4:45 pm (31124)


Acewell wrote:
i am beginning to take some interest in paletted textures now that i have a better understanding
of them thanks to the scripts you share. :D


yeh. this stuff is neato to puzzle. this alpha key or (color-key) is an old rendering trick. gif files use that too for semi-transparent gifs. how'd you do this script tho? i still can't download the script. could you post the bunch of code lines how you read the bmps palette or the whole file?!?

and... going back in 2017, i've been doing some weird things indeed. this oldschool and console stuff. the resident evil - dead aim (and gits-sac, cavia too) files were probably the sickest to crack with low level assembly. buffer shuffle madness. :D
  • Author
  • Localization

Acewell, posted Sat Dec 30, 2017 5:57 pm (31129)


episoder wrote:
i still can't download the script. could you post the bunch of code lines how you read the bmps palette or the whole file?!?

maybe browser cache issue? anyway here is the bmp reading section of the script :)
Code:
    #bmp 
    elif check == 0x8:
        imgWidth = bs.readUInt()
        imgHeight = bs.readUInt()
        num_pals = bs.readUShort()
        alpha_flag = bs.readUByte()
        bs.readByte()
        palette = []
        for i in range(num_pals):
            pal = bs.readUShort()
            red = (pal >> 4) & 0xf0
            green = (pal >> 0) & 0xf0
            blue = (pal             palette.append(blue)
            palette.append(green)
            palette.append(red)
            if i != alpha_flag:
                palette.append(0xff)
            else:
                palette.append(0x00)
        palette = bytearray(palette)
        datasize = imgWidth * imgHeight
        bs.seek(len(data) - datasize, NOESEEK_ABS)
        data = bs.readBytes(datasize)
        data = rapi.imageDecodeRawPal(data, palette, imgWidth, imgHeight, 8, "b8 g8 r8 a8")
        texList.append(NoeTexture(rapi.getInputName(), imgWidth, imgHeight, data, noesis.NOESISTEX_RGBA32))



edit
i uploaded the script again, check if it works for you now.
  • Author
  • Localization

episoder, posted Sat Dec 30, 2017 8:58 pm (31135)


nope. not a cache issue. got it now. i wasn't just sure how'd you modify the palette read. i got noesis syntax issues.

Code:
palette = bs.readBytes(num_pals * 2)
for i in range(num_pals):
    short palette[i] |= 0xF000
palette[alpha_flag] &= 0x0FFF
data = rapi.imageDecodeRawPal(data, palette, imgWidth, imgHeight, 8, "b4 g4 r4 a4")

would not work, right? i don't bother trying. lacks the array and short type cast perhaps anyway.

you did it manually too. so... this is clear now. :)
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.