16 bit textures

  • Thread starter Thread starter fuchisasquatch
  • Start date Start date
Status
Not open for further replies.
F

fuchisasquatch

Guest
I'm just mucking around and i put this TEX reader in my program and it works perfectly for 4/8 bit textures but i cant test it out on 16 bit textures cuz i cant find any.

So can anybody tell me if they know wheres some are..or even if there are any cuz im having a hard time finding any...
 
There were some, but where hmm ... maybe those FF8 opening screens, but they are in .lsz foromat so you have to unpack them first.
 
oh woops sorry...

i didnt specify which game i was talking about..i mean ff7..sorry bout that
 
oh woops sorry...

i didnt specify which game i was talking about..i mean ff7..sorry bout that
Are you speaking of the PC or PS1 version.
For FF7 there are not 16 bit textures. There are 16bit TIMs that are the game change backgroundds.  I believe the intro ICON is also a 16 bit TIM as well.

Cyb
 
Can anyone help me with these 16 bit tex's ?
I know that they're in format BGR 5-5-5, but I don't really know how to read 5 bits from a word in Delphi. And I know it has something to do with shl operator :P. Can somebody help me ?
 
Can anyone help me with these 16 bit tex's ?
I know that they're in format BGR 5-5-5, but I don't really know how to read 5 bits from a word in Delphi. And I know it has something to do with shl operator :P. Can somebody help me ?

5-5-5 is 15-bit not 16-bit.

Anyway, you would use a bitshift. In C this would be done like this (if you use rgb and the last bit is empty):

Code: [Select]
Code:
Uint16 numberToBeReadchar r, g, br = (numberToBeRead & 1111100000000000) >> 11g = (numberToBeRead & 0000011111000000) >> 6b = (numberToBeRead & 0000000000111110) >> 1

What these lines do is this. Let's say your incoming value is this:

1110110110110010

(numberToBeRead & 1111100000000000) will turn it into this:

1110100000000000

When you bitshift that, you will get this:

0000000000011101

After everything, your result will be this:

r = 11101
g = 10110
b = 11001

This code may need to be modified on computers with a different endian format.
 
'>>' means bit shift ? In delphi, there's shr command for this I think. Thanks for responce, I'll try this.

Edit: Actually, the unused bit is last, but first one, so binary values must be diffrent, already got that trick.
But now, how to convert it to 16-bit BMP format, which uses 3 bytes to describe one pixel ? Each of these colors is an integer in range 0..31, and in BMP file each color has 0..255. How to convert it ? Multiplying by 8 gives a 248 max value (or 8 minimal value).
 
Now that is going to be difficult. You might have to use a palette. I am unsure about how to do that.
 
In files that Texture Beast creates, there's no pallete. And for example, colors represented in tex as:
Code: [Select]
Code:
FF 7F

In BMP file that the program creates are:
Code: [Select]
Code:
FF FF FF

And so on...
 
I mean a palette look-up system. You would have a table of the correct values for each 5-bit color and use them.
 
I mean you could make a table of the right values manually.

Oh and I think the PSX uses BGR and not RGB.

Try multiplying the colors by 8. You are just going to have to accept the error for now.
 
5-5-5 is 15-bit not 16-bit.
Well actually it fits within 16 bits on a computer, unless the format is bit packed (which in this case would be plane silly and not all that useful). Hence it's 16bits even if only 15 bits are used.

Anyway, you would use a bitshift. In C this would be done like this (if you use rgb and the last bit is empty):

Excessive Quoting Removed

What these lines do is this. Let's say your incoming value is this:

1110110110110010

(numberToBeRead & 1111100000000000) will turn it into this:

1110100000000000

When you bitshift that, you will get this:

0000000000011101

After everything, your result will be this:

r = 11101
g = 10110
b = 11001

This code may need to be modified on computers with a different endian format.
That's assuming if the data was MSB justified. If it's LSB justified all your shifts are wrong. Also if it's the playstation version then it's 1:5:5:5  Alpha:Blue:Green:Red. If not then one has to be sure what the format is.  Either way, it's data dependant isn't it?

Anyhow on subject in Delphi it's shr more importantly it depends on what the original data is. If it's the playstation data you will end up creating 32 bit pixels (RGBA or ABGR depending on how your system is).

In C++ I use this
Code: [Select]
Code:
RGBA TMain::BGRTORGBA(UINT16 Clr){   RGBA Return;   Return.Red =   (Clr & 0x1F) <<3;   Return.Green = (Clr & 0x3E0) >>2;   Return.Blue =  (Clr & 0x7C00)>>10;   Return.Alpha =      (((Clr & 0x8000)|| (Clr == 0))>0)?0xFF:0x00;   return Return;}

Cyb - Good fortune!
 
I just said I was wrong. There textures are arranged 5 bits blue, 5 bits green, 5 bits red, and the extra bit.
 
I think Alhexx would help here, he writed Texture Beast so he knows this for sure. Alhexx, where are you ? :).
 
I think Alhexx would help here, he writed Texture Beast so he knows this for sure. Alhexx, where are you ? :).
What is Texture Beast?
Are you speaking of Ultima per chance?

sfx1999:
not really that big of a deal I wasn't beating on you or at least I wasn't trying to (needs to be qualified I suppose :D ).
 
I can help too, Biturn supports all the .TEX files aswell, and conversion to BMP too :)

if texture is in ARGB 1555 format it means that there is also alpha (transparency) information available; recalculation of the pixels into the RGBA 8888 format ( 4 bytes for a pixel ) would go like this:
Code: [Select]
Code:
alpha = original & 1;  //extract alpha bitoriginal >>= 1;        // remove bit from pixel, move all pixels to the rightred = original & 5;    // extract 5 bits for redred = red * 8;         // 5 bits store value 0 - 31, so we multiply it to keep value 0 - 255  ( 0 - 248 )original >>= 5;       // shift red out of the pixelgreen = ( original & 5 ) * 8;original >>= 5;       // shift green out of the pixelblue = ( original & 5 ) * 8;

and there you have it. Sometimes alpha information is useless, so you can just ignore it. If the pixel is stored in reverse order ( RGBA 5551 ) then you have to reverse order of the actions in the code.
 
Status
Not open for further replies.
Back
Top