Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: themanwiththemachinegun on 2004-12-16 23:22:33
-
hi, does anybody know a program to convert .lzs FF8 wallpaper files into .bmp image files? I know you can use Qhimms 'Eight' program, view the files on there and just do a screenshot and crop it but is there a program that will convert them into bitmaps for you?
thanks
-
I did it once, but i don't remember how .. i'll try to do it on the weekend and then i'll tell you. Well but anyhow why bother when you can do it with Eight ?
-
Try the codes listed below, compile under VC++6.0.
Can't remember when wrote this, many are copyed directly from the code of Eight. :D
#include<fstream.h>
#include<iostream.h>
#include<windows.h>
void main()
{
ifstream src(argc[1],ios::in|ios::binary);//lzs
ofstream dst(argc[2],ios::out|ios::binary);//bmp
if(!src||!dst)
{
cout<<"file open error.";
return;
}
// Load the texture
int iWidth=0, iHeight=0, iColors=0;
src.read((unsigned char *)&iColors,4);
if(iColors)src.seekg(0x10,ios::beg);
src.read((unsigned char *)&iWidth,2);
src.read((unsigned char *)&iHeight,2);
//strcture for bitmap
BITMAPINFO* bmi = (BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER));
bmi->bmiHeader.biBitCount = 16;
bmi->bmiHeader.biClrImportant = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biHeight = -iHeight;//must be negative
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
bmi->bmiHeader.biSizeImage = 0; //iWidth*iHeight*2
bmi->bmiHeader.biWidth = iWidth;
bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
/*
src.seekg(0xF0,ios::beg);//palette
src.read((unsigned char *)bmi->bmiColors,4*iColors);
for (int i=0;i<iColors;i++)
bmi->bmiColors[i].rgbReserved = 0;// Make sure rgbReserved is zero
*/
unsigned char *bits = (unsigned char*)malloc(iWidth*iHeight*2);//data
src.read(bits,iWidth*iHeight*2);
unsigned int tmpFlip,tmp;
for (int i=0;i<iWidth*iHeight*2;i+=2) {
tmp=bits[i]+(bits[i+1]<<8);
tmpFlip = (tmp & 0x7C00) >> 10; // Red -> Blue
tmpFlip |= (tmp & 0x07E0); // Green -> Green
tmpFlip |= (tmp & 0x001F) << 10; // Blue -> Red
tmp = tmpFlip;
bits[i]=tmp;bits[i+1]=tmp>>8;
}
// Build the bitmap file
BITMAPFILEHEADER bmfh;
//BITMAPINFOHEADER bmih;
bmfh.bfType = 'MB'; // BM (byteflipped)
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + iWidth*iHeight*2;
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
dst.write((unsigned char *)&bmfh, sizeof(bmfh));
dst.write((unsigned char *)&bmi->bmiHeader, sizeof(BITMAPINFOHEADER));
// dst.write((unsigned char *)bmi->bmiColors, iColors*sizeof(RGBQUAD));
// for (int j=0;j<iHeight;j++)
// dst.write(bits+(iHeight-j-1)*iWidth*2,iWidth*2); //if iHeight>0
dst.write(bits,iWidth*iHeight*2);
free(bmi);
free(bits);
src.close();
dst.close();
return;
}
-
I did it once, but i don't remember how .. i'll try to do it on the weekend and then i'll tell you. Well but anyhow why bother when you can do it with Eight ?
As an asside not, none of the intro images are findable in the PSX version. That leads me to believe they were also LZS compressed on the PSX version. I wonder how I can find this data now. Hunt sector by sector and decompress the first sector maybe?
Cyb
-
hey bspbsp was that code meant for me or for mirex? I don't program so I don't have VC++6.0 to compile it with. But thank you very much for doing it.
-
themanwiththemachinegun: try looking at the files with my tool Biturn I think it could view and convert them (but im not sure if they dont have to be unLZS-ed first ), download here: http://mirex.mypage.sk/FILES/bi085.rar
-
mirex, I have used Biturn before (it's a cool program, good work) but it didn't convert or view ff8 lzs files. But it was handy for converting other ff8 files.
Can someone help me and compile those codes bspbsp gave? I'm not a programmer and I don't have the software to do it. Would really aprecciate it. Thanks.