annotate system/visarc.cc @ 71:1fd20d231376

Fix objScale with 2D zoom; implement objWidth and objHeight.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 01 Apr 2011 23:49:12 +0200
parents 4416cfac86ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 #define CMDNAME "visarc"
223b71206888 Initial import
thib
parents:
diff changeset
2 #define VERSION "1.00"
223b71206888 Initial import
thib
parents:
diff changeset
3
223b71206888 Initial import
thib
parents:
diff changeset
4 /*****************************************
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
5 ** Visual Arts の圧縮書庫ファイルを
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
6 ** 展開する
0
223b71206888 Initial import
thib
parents:
diff changeset
7 **
223b71206888 Initial import
thib
parents:
diff changeset
8 ** usage : visarc x <arcfile> <file> [<file> ...]
223b71206888 Initial import
thib
parents:
diff changeset
9 ** visarc l <arcfile>
223b71206888 Initial import
thib
parents:
diff changeset
10 ** visarc g <arcfile> <graphic file>
223b71206888 Initial import
thib
parents:
diff changeset
11 ** visarc m <arcfile> <mask file>
223b71206888 Initial import
thib
parents:
diff changeset
12 **
223b71206888 Initial import
thib
parents:
diff changeset
13 ******************************************
223b71206888 Initial import
thib
parents:
diff changeset
14 */
223b71206888 Initial import
thib
parents:
diff changeset
15 /*
223b71206888 Initial import
thib
parents:
diff changeset
16 *
223b71206888 Initial import
thib
parents:
diff changeset
17 * Copyright (C) 2000- Kazunori Ueno(JAGARL) <jagarl@creator.club.ne.jp>
223b71206888 Initial import
thib
parents:
diff changeset
18 *
223b71206888 Initial import
thib
parents:
diff changeset
19 * This program is free software; you can redistribute it and/or modify
223b71206888 Initial import
thib
parents:
diff changeset
20 * it under the terms of the GNU General Public License as published by
223b71206888 Initial import
thib
parents:
diff changeset
21 * the Free Software Foundation; either version 2 of the License, or
223b71206888 Initial import
thib
parents:
diff changeset
22 * (at your option) any later version.
223b71206888 Initial import
thib
parents:
diff changeset
23 *
223b71206888 Initial import
thib
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful,
223b71206888 Initial import
thib
parents:
diff changeset
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
223b71206888 Initial import
thib
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223b71206888 Initial import
thib
parents:
diff changeset
27 * GNU General Public License for more details.
223b71206888 Initial import
thib
parents:
diff changeset
28 *
27
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
29 * You should have received a copy of the GNU General Public License along
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
30 * with this program; if not, write to the Free Software Foundation, Inc.,
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
31 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
223b71206888 Initial import
thib
parents:
diff changeset
32 *
223b71206888 Initial import
thib
parents:
diff changeset
33 */
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 #ifdef HAVE_CONFIG_H
223b71206888 Initial import
thib
parents:
diff changeset
36 # include "config.h"
223b71206888 Initial import
thib
parents:
diff changeset
37 #endif
223b71206888 Initial import
thib
parents:
diff changeset
38
223b71206888 Initial import
thib
parents:
diff changeset
39 #include <stdio.h>
223b71206888 Initial import
thib
parents:
diff changeset
40 #include <unistd.h>
223b71206888 Initial import
thib
parents:
diff changeset
41 #include <string.h>
223b71206888 Initial import
thib
parents:
diff changeset
42
223b71206888 Initial import
thib
parents:
diff changeset
43 // use only file subsystem
223b71206888 Initial import
thib
parents:
diff changeset
44 #include "file.h"
223b71206888 Initial import
thib
parents:
diff changeset
45 #include "file_impl.h"
223b71206888 Initial import
thib
parents:
diff changeset
46 // #include "file.cc"
223b71206888 Initial import
thib
parents:
diff changeset
47
223b71206888 Initial import
thib
parents:
diff changeset
48 #ifdef HAVE_LIBPNG
223b71206888 Initial import
thib
parents:
diff changeset
49 #include <png.h>
223b71206888 Initial import
thib
parents:
diff changeset
50 #endif
223b71206888 Initial import
thib
parents:
diff changeset
51
223b71206888 Initial import
thib
parents:
diff changeset
52 void usage(void) {
223b71206888 Initial import
thib
parents:
diff changeset
53 fprintf(stderr, "usage : visarc <cmd> <arcfile> [<file1> [<file2> [...] ]]\n");
223b71206888 Initial import
thib
parents:
diff changeset
54 fprintf(stderr, " cmd : x : extract\n");
223b71206888 Initial import
thib
parents:
diff changeset
55 fprintf(stderr, " l : list all files\n");
223b71206888 Initial import
thib
parents:
diff changeset
56 fprintf(stderr, "\n");
223b71206888 Initial import
thib
parents:
diff changeset
57 #ifdef HAVE_LIBPNG
223b71206888 Initial import
thib
parents:
diff changeset
58 fprintf(stderr, "usage2: visarc <cmd> <pdt-file> [<output-file>]\n");
223b71206888 Initial import
thib
parents:
diff changeset
59 fprintf(stderr, " cmd p : unpack pdt file and save as png file\n");
223b71206888 Initial import
thib
parents:
diff changeset
60 #endif /* HAVE_LIBPNG */
223b71206888 Initial import
thib
parents:
diff changeset
61 fprintf(stderr, "\n");
223b71206888 Initial import
thib
parents:
diff changeset
62 }
223b71206888 Initial import
thib
parents:
diff changeset
63
223b71206888 Initial import
thib
parents:
diff changeset
64 void List(char* path) {
223b71206888 Initial import
thib
parents:
diff changeset
65 ARCFILE* file;
223b71206888 Initial import
thib
parents:
diff changeset
66 FILE* f = fopen(path, "rb");
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
67 if (f == NULL) return;
0
223b71206888 Initial import
thib
parents:
diff changeset
68 char header[32];
223b71206888 Initial import
thib
parents:
diff changeset
69 fread(header, 32, 1, f);
223b71206888 Initial import
thib
parents:
diff changeset
70 fclose(f);
223b71206888 Initial import
thib
parents:
diff changeset
71 char magic_raf[8] = {'C','A','P','F',1,0,0,0};
223b71206888 Initial import
thib
parents:
diff changeset
72 if (strncmp(header, "PACL", 4) == 0) file = new ARCFILE(path);
223b71206888 Initial import
thib
parents:
diff changeset
73 else file = new SCN2kFILE(path);
223b71206888 Initial import
thib
parents:
diff changeset
74 file->Init();
223b71206888 Initial import
thib
parents:
diff changeset
75 file->ListFiles(stdout);
223b71206888 Initial import
thib
parents:
diff changeset
76 delete file;
223b71206888 Initial import
thib
parents:
diff changeset
77 }
223b71206888 Initial import
thib
parents:
diff changeset
78
223b71206888 Initial import
thib
parents:
diff changeset
79 void ExtractOne(ARCFILE* arc, char* file) {
223b71206888 Initial import
thib
parents:
diff changeset
80 ARCINFO* info = arc->Find(file,"");
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
81 if (info == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
82 fprintf(stderr, "Cannot find file %s in archive\n",file);
223b71206888 Initial import
thib
parents:
diff changeset
83 return;
223b71206888 Initial import
thib
parents:
diff changeset
84 }
223b71206888 Initial import
thib
parents:
diff changeset
85 FILE* out = fopen(file, "w");
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
86 if (out == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
87 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
88 fprintf(stderr, "Cannot open output file %s\n",file);
223b71206888 Initial import
thib
parents:
diff changeset
89 return;
223b71206888 Initial import
thib
parents:
diff changeset
90 }
223b71206888 Initial import
thib
parents:
diff changeset
91
223b71206888 Initial import
thib
parents:
diff changeset
92 fprintf(stdout, "Extracting %s ... ",file);
223b71206888 Initial import
thib
parents:
diff changeset
93 int size = info->Size();
223b71206888 Initial import
thib
parents:
diff changeset
94 const char* data = info->Read();
223b71206888 Initial import
thib
parents:
diff changeset
95 fwrite(data, size, 1, out);
223b71206888 Initial import
thib
parents:
diff changeset
96 fclose(out);
223b71206888 Initial import
thib
parents:
diff changeset
97 fprintf(stdout, "done\n");
223b71206888 Initial import
thib
parents:
diff changeset
98 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
99 }
223b71206888 Initial import
thib
parents:
diff changeset
100
223b71206888 Initial import
thib
parents:
diff changeset
101 void Extract(char* path, char** files, int fnum) {
223b71206888 Initial import
thib
parents:
diff changeset
102 ARCFILE* file;
223b71206888 Initial import
thib
parents:
diff changeset
103 FILE* f = fopen(path, "rb");
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
104 if (f == NULL) return;
0
223b71206888 Initial import
thib
parents:
diff changeset
105 char header[32];
223b71206888 Initial import
thib
parents:
diff changeset
106 fread(header, 32, 1, f);
223b71206888 Initial import
thib
parents:
diff changeset
107 fclose(f);
223b71206888 Initial import
thib
parents:
diff changeset
108 char magic_raf[8] = {'C','A','P','F',1,0,0,0};
223b71206888 Initial import
thib
parents:
diff changeset
109 if (strncmp(header, "PACL", 4) == 0) file = new ARCFILE(path);
223b71206888 Initial import
thib
parents:
diff changeset
110 else file = new SCN2kFILE(path);
223b71206888 Initial import
thib
parents:
diff changeset
111 file->Init();
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
112 if (files != NULL && fnum != 0) {
0
223b71206888 Initial import
thib
parents:
diff changeset
113 int i; for (i=0; i<fnum; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
114 ExtractOne(file, files[i]);
223b71206888 Initial import
thib
parents:
diff changeset
115 }
223b71206888 Initial import
thib
parents:
diff changeset
116 } else {
223b71206888 Initial import
thib
parents:
diff changeset
117 file->InitList();
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
118 char* path;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
119 while( (path=file->ListItem()) != 0) {
0
223b71206888 Initial import
thib
parents:
diff changeset
120 ExtractOne(file, path);
223b71206888 Initial import
thib
parents:
diff changeset
121 }
223b71206888 Initial import
thib
parents:
diff changeset
122 }
223b71206888 Initial import
thib
parents:
diff changeset
123 delete file;
223b71206888 Initial import
thib
parents:
diff changeset
124 }
223b71206888 Initial import
thib
parents:
diff changeset
125
223b71206888 Initial import
thib
parents:
diff changeset
126 void ChangeExt(char* path, char* new_ext, char* buf) {
223b71206888 Initial import
thib
parents:
diff changeset
127 char* name = strrchr(path, DIR_SPLIT);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
128 if (name == NULL) name = path;
0
223b71206888 Initial import
thib
parents:
diff changeset
129 else name++;
223b71206888 Initial import
thib
parents:
diff changeset
130 int path_len = name - path;
223b71206888 Initial import
thib
parents:
diff changeset
131
223b71206888 Initial import
thib
parents:
diff changeset
132 char* ext = strrchr(name, '.');
223b71206888 Initial import
thib
parents:
diff changeset
133 int ext_len;
223b71206888 Initial import
thib
parents:
diff changeset
134 if (ext) ext_len = ext - name;
223b71206888 Initial import
thib
parents:
diff changeset
135 else ext_len = strlen(name);
223b71206888 Initial import
thib
parents:
diff changeset
136
223b71206888 Initial import
thib
parents:
diff changeset
137 strncpy(buf, path, path_len+ext_len);
223b71206888 Initial import
thib
parents:
diff changeset
138 strcpy(buf+path_len+ext_len, new_ext);
223b71206888 Initial import
thib
parents:
diff changeset
139 }
223b71206888 Initial import
thib
parents:
diff changeset
140
223b71206888 Initial import
thib
parents:
diff changeset
141 char* ReadFile(char* fname, int* len) {
223b71206888 Initial import
thib
parents:
diff changeset
142 FILE* in = fopen(fname, "rb");
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
143 if (in == NULL) return 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
144 fseek(in, 0, SEEK_END);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
145 size_t s = ftell(in);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
146 fseek(in, 0, SEEK_SET);
0
223b71206888 Initial import
thib
parents:
diff changeset
147 char* buf = new char[s];
223b71206888 Initial import
thib
parents:
diff changeset
148 fread(buf,s,1,in);
223b71206888 Initial import
thib
parents:
diff changeset
149 fclose(in);
223b71206888 Initial import
thib
parents:
diff changeset
150 if (len) *len = s;
223b71206888 Initial import
thib
parents:
diff changeset
151 return buf;
223b71206888 Initial import
thib
parents:
diff changeset
152 }
223b71206888 Initial import
thib
parents:
diff changeset
153
223b71206888 Initial import
thib
parents:
diff changeset
154
223b71206888 Initial import
thib
parents:
diff changeset
155 #ifdef HAVE_LIBPNG
223b71206888 Initial import
thib
parents:
diff changeset
156 void create_png(FILE* stream, char* path, char* desc, int width, int height, char* data) {
223b71206888 Initial import
thib
parents:
diff changeset
157 png_structp png_ptr;
223b71206888 Initial import
thib
parents:
diff changeset
158 png_infop info_ptr;
223b71206888 Initial import
thib
parents:
diff changeset
159
223b71206888 Initial import
thib
parents:
diff changeset
160 /* create struct */
223b71206888 Initial import
thib
parents:
diff changeset
161 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
223b71206888 Initial import
thib
parents:
diff changeset
162 if (png_ptr == NULL) return;
223b71206888 Initial import
thib
parents:
diff changeset
163
223b71206888 Initial import
thib
parents:
diff changeset
164 /* initialize information */
223b71206888 Initial import
thib
parents:
diff changeset
165 info_ptr = png_create_info_struct(png_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
166 if (info_ptr == NULL) {
223b71206888 Initial import
thib
parents:
diff changeset
167 png_destroy_write_struct(&png_ptr, (png_infop*)NULL);
223b71206888 Initial import
thib
parents:
diff changeset
168 return;
223b71206888 Initial import
thib
parents:
diff changeset
169 }
223b71206888 Initial import
thib
parents:
diff changeset
170
223b71206888 Initial import
thib
parents:
diff changeset
171 if (setjmp(png_jmpbuf(png_ptr))) {
223b71206888 Initial import
thib
parents:
diff changeset
172 /* error occured !! */
223b71206888 Initial import
thib
parents:
diff changeset
173 png_destroy_write_struct(&png_ptr,&info_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
174 fprintf(stderr, "Get error while processing PNG from file %s\n",path);
223b71206888 Initial import
thib
parents:
diff changeset
175 return;
223b71206888 Initial import
thib
parents:
diff changeset
176 }
223b71206888 Initial import
thib
parents:
diff changeset
177
223b71206888 Initial import
thib
parents:
diff changeset
178 /* initialize I/O (for stream) */
223b71206888 Initial import
thib
parents:
diff changeset
179 png_init_io(png_ptr, stream);
223b71206888 Initial import
thib
parents:
diff changeset
180
223b71206888 Initial import
thib
parents:
diff changeset
181 /* initialize headers */
223b71206888 Initial import
thib
parents:
diff changeset
182 png_set_IHDR(png_ptr, info_ptr,
223b71206888 Initial import
thib
parents:
diff changeset
183 width, height, 8 /* bit_dept */,
223b71206888 Initial import
thib
parents:
diff changeset
184 PNG_COLOR_TYPE_RGB_ALPHA,
223b71206888 Initial import
thib
parents:
diff changeset
185 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
223b71206888 Initial import
thib
parents:
diff changeset
186 /* create text information */
223b71206888 Initial import
thib
parents:
diff changeset
187 png_text info_text[3];
223b71206888 Initial import
thib
parents:
diff changeset
188 info_text[0].key = "Title";
223b71206888 Initial import
thib
parents:
diff changeset
189 info_text[0].text= path;
223b71206888 Initial import
thib
parents:
diff changeset
190 info_text[0].compression = PNG_TEXT_COMPRESSION_NONE;
223b71206888 Initial import
thib
parents:
diff changeset
191 info_text[1].key = "Author";
223b71206888 Initial import
thib
parents:
diff changeset
192 info_text[1].text= CMDNAME " version " VERSION;
223b71206888 Initial import
thib
parents:
diff changeset
193 info_text[1].compression = PNG_TEXT_COMPRESSION_NONE;
223b71206888 Initial import
thib
parents:
diff changeset
194 info_text[2].key = "Description";
223b71206888 Initial import
thib
parents:
diff changeset
195 info_text[2].text= desc;
223b71206888 Initial import
thib
parents:
diff changeset
196 info_text[2].compression = PNG_TEXT_COMPRESSION_NONE;
223b71206888 Initial import
thib
parents:
diff changeset
197 png_set_text(png_ptr, info_ptr, info_text, 3);
223b71206888 Initial import
thib
parents:
diff changeset
198
223b71206888 Initial import
thib
parents:
diff changeset
199 /* write information */
223b71206888 Initial import
thib
parents:
diff changeset
200 png_write_info(png_ptr, info_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
201
223b71206888 Initial import
thib
parents:
diff changeset
202 /* write body */
223b71206888 Initial import
thib
parents:
diff changeset
203 /* rgba image ; input/output is 32bpp.*/
223b71206888 Initial import
thib
parents:
diff changeset
204 char* row = new char[width*4];
223b71206888 Initial import
thib
parents:
diff changeset
205 int i; for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
206 char* row_ptr = row;
223b71206888 Initial import
thib
parents:
diff changeset
207 int j; for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
208 row_ptr[0] = data[2];
223b71206888 Initial import
thib
parents:
diff changeset
209 row_ptr[1] = data[1];
223b71206888 Initial import
thib
parents:
diff changeset
210 row_ptr[2] = data[0];
223b71206888 Initial import
thib
parents:
diff changeset
211 row_ptr[3] = data[3];
223b71206888 Initial import
thib
parents:
diff changeset
212 row_ptr += 4; data += 4;
223b71206888 Initial import
thib
parents:
diff changeset
213 }
223b71206888 Initial import
thib
parents:
diff changeset
214 png_write_rows(png_ptr, (png_byte**)&row, 1);
223b71206888 Initial import
thib
parents:
diff changeset
215 }
223b71206888 Initial import
thib
parents:
diff changeset
216 png_write_end(png_ptr, info_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
217 png_destroy_write_struct(&png_ptr, &info_ptr);
223b71206888 Initial import
thib
parents:
diff changeset
218 }
223b71206888 Initial import
thib
parents:
diff changeset
219
223b71206888 Initial import
thib
parents:
diff changeset
220 void ExtractPngRgbaGraphic(char* path,char* outpath = 0) {
223b71206888 Initial import
thib
parents:
diff changeset
221 char buf[1024]; char* fname = buf;
223b71206888 Initial import
thib
parents:
diff changeset
222 int len;
223b71206888 Initial import
thib
parents:
diff changeset
223 char* dat = ReadFile(path, &len);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
224 if (dat == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
225 fprintf(stderr, "Cannot open PDT file : %s\n",path);
223b71206888 Initial import
thib
parents:
diff changeset
226 return;
223b71206888 Initial import
thib
parents:
diff changeset
227 }
223b71206888 Initial import
thib
parents:
diff changeset
228 GRPCONV* conv = GRPCONV::AssignConverter(dat, len, path);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
229 if (conv == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
230 fprintf(stderr, "Invalid format\n");
223b71206888 Initial import
thib
parents:
diff changeset
231 return;
223b71206888 Initial import
thib
parents:
diff changeset
232 }
223b71206888 Initial import
thib
parents:
diff changeset
233 bool masked = conv->IsMask();
223b71206888 Initial import
thib
parents:
diff changeset
234 char* data = new char[conv->Width() * conv->Height() * 4 + 1024];
223b71206888 Initial import
thib
parents:
diff changeset
235 if (! conv->Read(data)) {
223b71206888 Initial import
thib
parents:
diff changeset
236 fprintf(stderr, "Insufficient memory\n");
223b71206888 Initial import
thib
parents:
diff changeset
237 delete conv;
223b71206888 Initial import
thib
parents:
diff changeset
238 return;
223b71206888 Initial import
thib
parents:
diff changeset
239 }
223b71206888 Initial import
thib
parents:
diff changeset
240 if (! masked) {
223b71206888 Initial import
thib
parents:
diff changeset
241 for (int i = 0; i < conv->Width() * conv->Height(); i++) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
242 data[4*i+3] = 0xff; // 不透明度を最大にする
0
223b71206888 Initial import
thib
parents:
diff changeset
243 }
223b71206888 Initial import
thib
parents:
diff changeset
244 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
245 if (outpath == NULL) ChangeExt(path,".png", buf); // path をつくる
0
223b71206888 Initial import
thib
parents:
diff changeset
246 else fname = outpath;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
247 FILE* out = fopen(fname, "wb"); // ファイルを開く
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 27
diff changeset
248 if (out == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
249 fprintf(stderr, "Cannot open raw file : %s\n",buf);
223b71206888 Initial import
thib
parents:
diff changeset
250 delete conv;
223b71206888 Initial import
thib
parents:
diff changeset
251 return;
223b71206888 Initial import
thib
parents:
diff changeset
252 }
223b71206888 Initial import
thib
parents:
diff changeset
253 create_png(out, path, "", conv->Width(), conv->Height(), data);
223b71206888 Initial import
thib
parents:
diff changeset
254 fclose(out);
223b71206888 Initial import
thib
parents:
diff changeset
255
223b71206888 Initial import
thib
parents:
diff changeset
256 delete conv;
223b71206888 Initial import
thib
parents:
diff changeset
257 }
223b71206888 Initial import
thib
parents:
diff changeset
258 #endif /* HAVE_LIBPNG */
223b71206888 Initial import
thib
parents:
diff changeset
259
223b71206888 Initial import
thib
parents:
diff changeset
260 int main(int argc, char* argv[]) {
223b71206888 Initial import
thib
parents:
diff changeset
261 int i;
223b71206888 Initial import
thib
parents:
diff changeset
262 fprintf(stderr, "%s version %s\n", CMDNAME, VERSION);
223b71206888 Initial import
thib
parents:
diff changeset
263 if (argc < 3) {
223b71206888 Initial import
thib
parents:
diff changeset
264 usage(); return -1;
223b71206888 Initial import
thib
parents:
diff changeset
265 }
223b71206888 Initial import
thib
parents:
diff changeset
266 if (strlen(argv[1]) != 1) {
223b71206888 Initial import
thib
parents:
diff changeset
267 usage(); return -1;
223b71206888 Initial import
thib
parents:
diff changeset
268 }
223b71206888 Initial import
thib
parents:
diff changeset
269 for (i=2; i<argc; i++) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
270 /* option を削る */
0
223b71206888 Initial import
thib
parents:
diff changeset
271 argc--;
223b71206888 Initial import
thib
parents:
diff changeset
272 int j; for (j=i; j<argc; j++) argv[j] = argv[j+1];
223b71206888 Initial import
thib
parents:
diff changeset
273 }
223b71206888 Initial import
thib
parents:
diff changeset
274 switch(argv[1][0]) {
223b71206888 Initial import
thib
parents:
diff changeset
275 case 'x': case 'X':
223b71206888 Initial import
thib
parents:
diff changeset
276 if (argc < 4) Extract(argv[2], 0, -1);
223b71206888 Initial import
thib
parents:
diff changeset
277 else Extract(argv[2], argv+3, argc-3);
223b71206888 Initial import
thib
parents:
diff changeset
278 break;
223b71206888 Initial import
thib
parents:
diff changeset
279 case 'l': case 'L':
223b71206888 Initial import
thib
parents:
diff changeset
280 List(argv[2]);
223b71206888 Initial import
thib
parents:
diff changeset
281 break;
223b71206888 Initial import
thib
parents:
diff changeset
282 #ifdef HAVE_LIBPNG
223b71206888 Initial import
thib
parents:
diff changeset
283 case 'p': case 'P':
223b71206888 Initial import
thib
parents:
diff changeset
284 case 'a': case 'A':
223b71206888 Initial import
thib
parents:
diff changeset
285 if (argc < 4)
223b71206888 Initial import
thib
parents:
diff changeset
286 ExtractPngRgbaGraphic(argv[2]);
223b71206888 Initial import
thib
parents:
diff changeset
287 else
223b71206888 Initial import
thib
parents:
diff changeset
288 ExtractPngRgbaGraphic(argv[2],argv[3]);
223b71206888 Initial import
thib
parents:
diff changeset
289 break;
223b71206888 Initial import
thib
parents:
diff changeset
290 #endif /* HAVE_LIBPNG */
223b71206888 Initial import
thib
parents:
diff changeset
291 default:
223b71206888 Initial import
thib
parents:
diff changeset
292 usage(); return -1;
223b71206888 Initial import
thib
parents:
diff changeset
293 }
223b71206888 Initial import
thib
parents:
diff changeset
294 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
295 }