• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

swfから画像を抽出するコマンドラインアプリケーション


Commit MetaInfo

Revision1f0b48fd173294a44eb112816ea0b9f202ed5486 (tree)
Zeit2016-09-18 23:36:57
Autormasakih <masakih@user...>
Commitermasakih

Log Message

charactorIDによる抽出が正しく動いていなかったので修正

Ändern Zusammenfassung

Diff

--- a/KanColleGraphicDivider/main.m
+++ b/KanColleGraphicDivider/main.m
@@ -39,6 +39,17 @@ void printHex(const unsigned char *p) {
3939 }
4040
4141
42+enum {
43+ tagBits = 6,
44+ tagJPEGTables = 8, // not supported
45+ tagBitsJPEG2 = 21, // not supported
46+ tagBitsJPEG3 = 35,
47+ tagBitsLossless = 20, // not supported
48+ tagBitsLossless2 = 36,
49+ tagBitsJPEG4 = 90, // not supported
50+
51+};
52+
4253 const char *toolName;
4354 const char *versionString = "1.0";
4455
@@ -101,6 +112,10 @@ void saveImageAsPNG(id image, UInt16 charactorID) {
101112
102113 void storeImage(const unsigned char *p, UInt32 length, UInt16 charactorID) {
103114 printLog("#### TYPE IS PICTURE ####\n\n");
115+
116+ printLog("CaractorID is %d\n", charactorID);
117+ if(skipCharactorID(charactorID)) return;
118+
104119 if(length == 0) return;
105120
106121 NSData *pic = [NSData dataWithBytes:p length:length];
@@ -292,7 +307,7 @@ void storeBitsLossless2(const unsigned char *p, UInt32 length) {
292307 int main(int argc, char * const *argv) {
293308 @autoreleasepool {
294309
295-
310+ // 引数の処理
296311 int opt;
297312 char *filename = NULL;
298313 char *oFilename = NULL;
@@ -309,7 +324,6 @@ int main(int argc, char * const *argv) {
309324 {NULL, 0, NULL, 0}
310325 };
311326
312-
313327 while((opt = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) {
314328 switch(opt) {
315329 case 'o':
@@ -332,6 +346,8 @@ int main(int argc, char * const *argv) {
332346
333347 if(optind < argc) {
334348 filename = argv[optind];
349+ } else {
350+ usage(EXIT_FAILURE, stderr);
335351 }
336352
337353 if(oFilename) {
@@ -374,6 +390,7 @@ int main(int argc, char * const *argv) {
374390 sOriginalName = [filePath lastPathComponent];
375391 sOriginalName = [sOriginalName stringByDeletingPathExtension];
376392
393+
377394 printHex(data.bytes);
378395
379396 // ヘッダの処理開始
@@ -434,27 +451,27 @@ int main(int argc, char * const *argv) {
434451
435452 // 画像の時の処理
436453 switch(tag) {
437- case 6:
454+ case tagBits:
438455 @autoreleasepool {
439456 storeImage(p + 2, length - 2, *(UInt16 *)p);
440457 }
441458 break;
442- case 35:
459+ case tagBitsJPEG3:
443460 @autoreleasepool {
444461 storeBitsJPEG3(p, length);
445462 }
446463 break;
447- case 36:
464+ case tagBitsLossless2:
448465 @autoreleasepool {
449466 storeBitsLossless2(p, length);
450467 }
451468 break;
452- case 8:
453- case 21:
454- case 20:
455- case 90:
456- @autoreleasepool {
457- storeImage(p, length, *(UInt16 *)p);
469+ case tagBitsJPEG2:
470+ case tagBitsLossless:
471+ case tagBitsJPEG4:
472+ case tagJPEGTables:
473+ if(length > 0) {
474+ fprintf(stderr, "Not supported type. (tag=%d)\n", tag);
458475 }
459476 break;
460477 }