home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fun CD 26
/
OTACD26.ISO
/
archive
/
game
/
kaqcut
/
kaqcut.lzh
/
KAQCUT.C
next >
Wrap
C/C++ Source or Header
|
1997-09-20
|
3KB
|
95 lines
/*---------------------------------------------------
SS 下級生 BMP.ARC 分割プログラム
ver 0.00 1997/09/17
By 浦木 コウ
----------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BMP_HEADER_SIZE 0x436L /* パレットとヘッダを足したサイズ */
#define MAX_FILE 94 /* 分割後のファイルの数 */
main(int ac, char **av)
{
long offsets[]={0x0,0x4000,0x8000,0xC000,0x10000,0x14000,0x18000,0x1C000,
0xA2800,0xE9000,0xED000,0xF1000,0xF5000,0xF9000,0xFD000,
0x101000,0x153000,0x176800,0x1E7000,0x226000,0x265000,0x294800,
0x323800,0x327800,0x32B800,0x32F800,0x333800,0x337800,0x33B800,
0x33F800,0x343800,0x347800,0x34B800,0x34F800,0x353800,0x357800,
0x35B800,0x35F800,0x363800,0x367800,0x36B800,0x36F800,0x373800,
0x377800,0x37B800,0x37F800,0x383800,0x387800,0x3C6800,0x3CA800,
0x3CE800,0x3D2800,0x3D6800,0x3DA800,0x3DE800,0x3E2800,0x3E6800,
0x3EA800,0x3EE800,0x3F2800,0x3F6800,0x3FA800,0x3FE800,0x402800,
0x406800,0x40A800,0x40E800,0x412800,0x416800,0x41A800,0x41E800,
0x422800,0x426800,0x42A800,0x42E800,0x432800,0x436800,0x43A800,
0x43E800,0x442800,0x446800,0x44A800,0x44E800,0x48D800,0x491800,
0x495800,0x499800,0x49D800,0x4A1800,0x4C5000,0x4E8800,0x4EC800,
0x52B800,0x56A800};
long fsize;
unsigned char hbuf[BMP_HEADER_SIZE], lbuf[640], fname[100], *ext=".BMP";
int i, j, w, h, h2;
FILE *fp1, *fp2;
printf("SS 下級生 'BMP.ARC' 分割プログラム ver 0.00\n"
"\t\t\tBy 浦木 コウ\n");
if(ac<2)
{
printf(" usage:kaqcut [origin file]\n");
return 0;
}
fp1=fopen(av[1],"rb"); /* 元ファイルオープン */
if(fp1==NULL)
{
printf("not found:%s\n",av[1]);
return -1;
}
for(i=0;i<MAX_FILE;i++) /* ファイル書き込み */
{
itoa(i+1,fname,10); /* ファイルネーム作成 */
strcat(fname,ext);
fp2=fopen(fname,"wb");
if(fp2==NULL)
{
printf("file open error:%s\n",fname);
fclose(fp1);
return -1;
}
fseek(fp1,offsets[i],SEEK_SET);
fread(hbuf,BMP_HEADER_SIZE,sizeof(unsigned char),fp1);
w=hbuf[0x12]+hbuf[0x13]*0x100; /* 幅取得 */
h=hbuf[0x16]+hbuf[0x17]*0x100; /* 高さ取得 */
h2=h*2; /* 高さを2倍にして、ファイルサイズ再計算 */
fsize=BMP_HEADER_SIZE+(long)w*(long)h2;
hbuf[0x16]=h2%0x100; /* 高さデータ変更 */
hbuf[0x17]=h2/0x100;
hbuf[2]=fsize%0x100L; /* ファイルサイズ変更 */
hbuf[3]=(fsize%0x10000L)/0x100L;
hbuf[4]=fsize/0x10000L;
fwrite(hbuf,BMP_HEADER_SIZE,sizeof(unsigned char),fp2); /*ヘッダ書き込み*/
for(j=0;j<h;j++)
{
fread(lbuf,w,sizeof(unsigned char),fp1);
fwrite(lbuf,w,sizeof(unsigned char),fp2); /* 2ライン書き込む */
fwrite(lbuf,w,sizeof(unsigned char),fp2);
}
fclose(fp2);
}
fclose(fp1);
return 1;
}