📄 mga_cut.c
字号:
/* (c) HelDoRe Dr. Halo CUT unit ... v0.0.4 Supported formats :*/ #define VERCUT " unit v0.0.4"#include <stdio.h>#include "../mga_view.h"void help_cut(){printf("CUT%s\n + 8 bpp\n",VERCUT);}int detect_cut(){ int rle,ile; FILE *paleta; char pal[100]; image_x=fgetc16b(plik); image_y=fgetc16b(plik); fseek(plik,4,SEEK_CUR); if (check_image(image_x,image_y,8)==3) return 3; printf("CUT & PAL%s\n",VERCUT); printf("Maybe CUT file : %ix%i\n",image_x,image_y); tempi=0; do { pal[tempi]=mee[tempi]; tempi++; } while ((mee[tempi] != 46) && (tempi!=strlen(mee))); pal[tempi++]=46; pal[tempi++]=112; pal[tempi++]=97; pal[tempi++]=108; pal[tempi++]=0; ile=0; if ((paleta=fopen(pal,"r")) != NULL) { ile=1; tempi=fgetc16(paleta); if (tempi != 16712) { printf("File %s is not PAL file !\n",pal); ile=0; } else { fseek(paleta,10,SEEK_CUR); tempi=fgetc16b(paleta); fseek(paleta,6,SEEK_CUR); rle=fgetc32b(paleta); if (rle != 539914820) ile=0; rle=fgetc32(paleta); if (rle != 1214344303) ile=0; fseek(paleta,12,SEEK_CUR); if (ile==1) for (y=0;y<256;y++) { tab2r[y]=(fgetc16b(paleta)>>8); tab2g[y]=(fgetc16b(paleta)>>8); tab2b[y]=(fgetc16b(paleta)>>8); } } } else printf("File %s not found !\n",pal); if (ile==0) { for (y=0;y<256;y++) { tab2r[y]=y/2; tab2g[y]=y/4; tab2b[y]=y; } } for (y=0;y<image_y;y++) { for (x=0;x<image_x;x++) { if ((ile=fgetc(plik))==-1) return 0; if (ile>127) { tempi=fgetc(plik); for (rle=0;rle<(ile-128);rle++) { tabr[y*image_x+x]=tab2r[tempi]; tabg[y*image_x+x]=tab2g[tempi]; tabb[y*image_x+x++]=tab2b[tempi]; } } else if (ile!=0){ for (rle=0;rle<(ile);rle++) { tempi=fgetc(plik); tabr[y*image_x+x]=tab2r[tempi]; tabg[y*image_x+x]=tab2g[tempi]; tabb[y*image_x+x++]=tab2b[tempi]; } } if (ile==0) { tempi=fgetc(plik); tempi=fgetc(plik); x++; } x--; }} return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -