-
Despero
-
-
Вне сайта
-
Путник
-
- Сообщений: 8
-
-
|
В общем проблема такая.........
Нашол в инете много чарсетов, но в итоге ни один из них так и не подошол, тк все они либо для 2к, либо для 2к3, думал думал, лазил лазил, и нашол в инете скрипт который конвертирует их в ХР но млин я даж нинаю как пользоваться этими скриптами, может ктонибудь знает ответ???
Помогите плз.....
Вот сам скрипт
// RPG2000/RPG2003 to RPGXP converter
#include <windows.h>
#include <iostream>
using namespace std;
// This holds the old character set
RGBQUAD palette[256];
unsigned char old_image[288*256];
void load_set(char *filename)
{
// Loads an old character set
BITMAPINFOHEADER bih;
BITMAPFILEHEADER bfh;
HANDLE hfile;
DWORD written;
unsigned char *bozodata;
// Confirm
cout<<"Loading image...";
// Extract the palette from the image
hfile = CreateFile(filename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL);
ReadFile(hfile,&bfh,sizeof(bfh),&written,NULL);
ReadFile(hfile,&bih,sizeof(bih),&written,NULL);
ReadFile(hfile,&palette,sizeof(palette),&written,NULL);
CloseHandle(hfile);
// Extract the bits from the image
hfile = CreateFile(filename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL);
bozodata = new unsigned char[bfh.bfOffBits];
ReadFile(hfile,bozodata,bfh.bfOffBits,&written,NULL);
ReadFile(hfile,&old_image[0],288*256,&written,NULL);
CloseHandle(hfile);
delete bozodata;
// Complete
cout<<"Done!\n";
}
// This contains all seperate eight images of the old character set in proper orientation
unsigned char sep_image[8][72][128];
#define GET_PIXEL(x,y) old_image[(x)+(((y))*288)] // Macro for getting pixels
void chop_set()
{
int set_on = 0; // Current character to seperate
// Confirm
cout<<"Seperating characters...";
// Seperates each character from the old set
for(int y = 0;y < 256;y += 128)
{
for(int x = 0;x < 288;x += 72)
{
for(int py = 0;py < 128;py++)
{
for(int px = 0;px < 72;px++)
{
sep_image[set_on][px][py] = GET_PIXEL(x+px,y+py);
}
}
// Advance character
set_on++;
}
}
// Complete
cout<<"Done!\n";
}
// This contains the vertically correct XP version of the previous step
unsigned char vconv_image[8][96][128];
void vert_convert()
{
// Confirm
cout<<"Vertical phase...";
// Copy normally
for(int index = 0;index < 8;index++)
{
for(int y = 0;y < 128;y++)
{
for(int x = 0;x < 72;x++)
{
vconv_image[index][x][y] = sep_image[index][x][y];
}
}
}
// Copy and paste vertical slice
for(int index = 0;index < 8;index++)
{
for(int y = 0;y < 128;y++)
{
for(int x = 0;x < 24;x++)
{
vconv_image[index][x+24+48][y] = vconv_image[index][x+24][y];
}
}
}
// Complete
cout<<"Done!\n";
}
// This contains the correct XP version of the previous two steps
unsigned char hconv_image[8][96][128];
void horz_convert()
{
// Confirm
cout<<"Horizontal phase...";
// Horizontal slice copy
for(int index = 0;index < 8;index++)
{
// Copy the frame for standing up to slot 4 (index 3)
for(int y = 0;y < 32;y++)
{
for(int x = 0;x < 96;x++)
{
hconv_image[index][x][y] = vconv_image[index][x][y+(32*3)];
}
}
// Copy the frame for standing right to slot 3 (index 2)
for(int y = 0;y < 32;y++)
{
for(int x = 0;x < 96;x++)
{
hconv_image[index][x][y+(32*1)] = vconv_image[index][x][y+(32*2)];
}
}
// Copy the frame for standing down to slot 1 (index 0)
for(int y = 0;y < 32;y++)
{
for(int x = 0;x < 96;x++)
{
hconv_image[index][x][y+(32*3)] = vconv_image[index][x][y+(32*1)];
}
}
// Copy the frame for standing left to slot 2 (index 1)
for(int y = 0;y < 32;y++)
{
for(int x = 0;x < 96;x++)
{
hconv_image[index][x][y+(32*2)] = vconv_image[index][x][y];
}
}
}
// Complete
cout<<"Done!\n";
}
// This contains the final images in twice the size for complete XP conversion
unsigned char final_image[8][96*2][128*2];
void final_convert()
{
// Confirm
cout<<"Doubling images...";
// Simply copy to twice the size!
for(int index = 0;index < 8;index++)
{
for(int y = 0;y < 128*2;y += 2)
{
for(int x = 0;x < 96*2;x += 2)
{
final_image[index][x][y] = hconv_image[index][x/2][y/2];
final_image[index][x+1][y] = hconv_image[index][x/2][y/2];
final_image[index][x][y+1] = hconv_image[index][x/2][y/2];
final_image[index][x+1][y+1] = hconv_image[index][x/2][y/2];
}
}
}
// Complete
cout<<"Done!\n";
}
// At last, write the output files
char xpname[10];
void output_convert()
{
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
HANDLE hfile;
DWORD written;
// Confirm
cout<<"Outputing images:\n";
// Prepare the headers
cout<<"Preparing headers...";
bfh.bfOffBits = sizeof(bfh)+sizeof(bih)+sizeof(palette);
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
bfh.bfSize = sizeof(bfh);
bfh.bfType = 0x4D42;
bih.biBitCount = 8;
bih.biClrImportant = 256;
bih.biClrUsed = 256;
bih.biCompression = BI_RGB;
bih.biHeight = 128*2;
bih.biPlanes = 1;
bih.biSize = sizeof(bih);
bih.biSizeImage = 256*288;
bih.biWidth = 96*2;
bih.biXPelsPerMeter = 2400;
bih.biYPelsPerMeter = 2400;
cout<<"Done!\n";
// Begin writng the files
for(int index = 0;index < 8;index++)
{
// Copy correct name
for(int t = 0;t < 10;t++)
xpname[t] = 0;
xpname[0] = 'c';
xpname[1] = 'o';
xpname[2] = 'n';
xpname[3] = 'v';
xpname[4] = '1'+(7-index);
xpname[5] = '.';
xpname[6] = 'b';
xpname[7] = 'm';
xpname[8] = 'p';
// Confirm
cout<<"Writing file conv"<<(index+1)<<".bmp now...";
// Open a channel to that file
hfile = CreateFile(xpname,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
WriteFile(hfile,&bfh,sizeof(bfh),&written,NULL);
WriteFile(hfile,&bih,sizeof(bih),&written,NULL);
WriteFile(hfile,&palette,sizeof(palette),&written,NULL);
for(int y = 0;y < 128*2;y++)
{
for(int x = 0;x < 96*2;x++)
{
WriteFile(hfile,&final_image[index][x][y],1,&written,NULL);
}
}
CloseHandle(hfile);
// Complete
cout<<"Done!\n";
}
// End of program
cout<<"Full conversion complete.\n";
}
// Program entry
void main(int argn,char *argc[])
{
// Step 1: Load the old character set
load_set(&argc[1][0]);
// Step 2: Seperate the characters into indiviual images
chop_set();
// Step 3: Vertical phase the set
vert_convert();
// Step 4: Horizontal phase the set
horz_convert();
// Step 5: Size double the set
final_convert();
// Step 6: Output results
output_convert();
}
|