| View previous topic :: View next topic |
| Author |
Message |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Tue Apr 03, 2007 7:12 am Post subject: Unswizzling a texture |
|
|
Hello ^^
I'm trying to unswizzle a texture but I can't understand correctly what is written here :( It's sooo complicated, especially for me who doesn't understand english very well :(
I've searched a lot but didn't found any code that does unswizzling.
So I'm asking here: can someone post a routine for unswizzling a texture please? :)
Thank you very much in advance,
Brunni _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Tue Apr 03, 2007 9:43 am Post subject: |
|
|
| Code: |
void unswizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int height)
{
unsigned int blockx, blocky;
unsigned int i,j;
unsigned int width_blocks = (width / 16);
unsigned int height_blocks = (height / 8);
unsigned int dst_pitch = (width-16)/4;
unsigned int dst_row = width * 8;
u32* src = (u32*)in;
u8* ydst = out;
for (blocky = 0; blocky < height_blocks; ++blocky)
{
const u8* xdst = ydst;
for (blockx = 0; blockx < width_blocks; ++blockx)
{
const u32* dst= (u32*)xdst;
for (j = 0; j < 8; ++j)
{
*(dst++) = *(src++);
*(dst++) = *(src++);
*(dst++) = *(src++);
*(dst++) = *(src++);
dst += dst_pitch;
}
xdst += 16;
}
ydst += dst_row;
}
}
|
Try with that. It's untested though, but you can work from there if it doesn't give correct results immediately. Basically, you just revert the code from the swizzle function. _________________ <Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
Alexander Berl |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Wed Apr 04, 2007 2:37 am Post subject: |
|
|
Soooo kind of you :)
It works, thank you so much :D _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
|