• 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

Revision6820c3c720c9ed8b35023fd9f9532c727b5fabbd (tree)
Zeit2018-05-22 22:59:06
Autormasakih <masakih@user...>
Commitermasakih

Log Message

不要な部分を削除。書式をそろえた

Ändern Zusammenfassung

Diff

--- a/KanColleGraphicDivider.xcodeproj/project.pbxproj
+++ b/KanColleGraphicDivider.xcodeproj/project.pbxproj
@@ -51,7 +51,6 @@
5151 F490569220B0512C00CF637D /* Information.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Information.m; sourceTree = "<group>"; };
5252 F490569420B0568F00CF637D /* ImageStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageStore.h; sourceTree = "<group>"; };
5353 F490569520B0568F00CF637D /* ImageStore.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageStore.m; sourceTree = "<group>"; };
54- F490569720B0584600CF637D /* KanColleGraphicDivider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KanColleGraphicDivider.h; sourceTree = "<group>"; };
5554 F490569820B059B800CF637D /* BitLossless2ColorTableDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BitLossless2ColorTableDecoder.h; sourceTree = "<group>"; };
5655 F490569920B059B800CF637D /* BitLossless2ColorTableDecoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BitLossless2ColorTableDecoder.m; sourceTree = "<group>"; };
5756 F490569B20B05B9400CF637D /* BitsJPEG3Decoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BitsJPEG3Decoder.h; sourceTree = "<group>"; };
@@ -97,7 +96,6 @@
9796 isa = PBXGroup;
9897 children = (
9998 F486709E20B30A3D00DB9579 /* mics */,
100- F490569720B0584600CF637D /* KanColleGraphicDivider.h */,
10199 F44C14C11D84F27500ADE497 /* SWFStructure.h */,
102100 F44C14BA1D84F07300ADE497 /* main.m */,
103101 F486709C20B30A2300DB9579 /* SWFParser */,
--- a/KanColleGraphicDivider/Decoder/BitLossless2ColorTableDecoder.m
+++ b/KanColleGraphicDivider/Decoder/BitLossless2ColorTableDecoder.m
@@ -8,8 +8,7 @@
88
99 #import "BitLossless2ColorTableDecoder.h"
1010
11-#include "KanColleGraphicDivider.h"
12-#import "Information.h"
11+#include "SWFStructure.h"
1312 #import "ImageDataConverter.h"
1413
1514 #import "HMZlibData.h"
@@ -71,13 +70,16 @@
7170 // ARGBカラーマップからARGBビットマップを作成
7271 UInt32 *imageDataP = calloc(4, data->width * data->height);
7372 if(!imageDataP) {
73+
7474 fprintf(stderr, "Can not allocate enough memory.\n");
7575 return nil;
7676 }
7777
7878 UInt32 *imageDataPixel = imageDataP;
7979 for(UInt16 h = 0; h < data->height; h++) {
80+
8081 for(UInt16 w = 0; w < data->width; w++) {
82+
8183 *imageDataPixel++ = mapP[*colorIndexP++];
8284 }
8385 colorIndexP += skipBytes;
--- a/KanColleGraphicDivider/Decoder/BitsDecoder.m
+++ b/KanColleGraphicDivider/Decoder/BitsDecoder.m
@@ -52,6 +52,7 @@
5252
5353 NSImage *pict = [[NSImage alloc] initWithData:contentData];
5454 if(!pict) {
55+
5556 fprintf(stderr, "Can not create image from data.\n");
5657 return nil;
5758 }
--- a/KanColleGraphicDivider/Decoder/BitsJPEG3Decoder.m
+++ b/KanColleGraphicDivider/Decoder/BitsJPEG3Decoder.m
@@ -8,7 +8,7 @@
88
99 #import "BitsJPEG3Decoder.h"
1010
11-#include "KanColleGraphicDivider.h"
11+#include "SWFStructure.h"
1212 #import "ImageDataConverter.h"
1313
1414 #import "BitsDecoder.h"
@@ -75,6 +75,7 @@
7575 NSData *pic = [NSData dataWithBytes:p length:imageSize];
7676 NSImage *pict = [[NSImage alloc] initWithData:pic];
7777 if(!pict) {
78+
7879 fprintf(stderr, "Can not create image from data.\n");
7980 return nil;
8081 }
@@ -97,6 +98,7 @@
9798 bytesPerRow:size.width
9899 bitsPerPixel:0];
99100 if(!alphaImageRef) {
101+
100102 fprintf(stderr, "Can not create alpha image from data.\n");
101103 return nil;
102104 }
--- a/KanColleGraphicDivider/Decoder/BitsLossless2Decoder.m
+++ b/KanColleGraphicDivider/Decoder/BitsLossless2Decoder.m
@@ -8,7 +8,7 @@
88
99 #import "BitsLossless2Decoder.h"
1010
11-#include "KanColleGraphicDivider.h"
11+#include "SWFStructure.h"
1212 #import "ImageDataConverter.h"
1313
1414 #import "HMZlibData.h"
--- a/KanColleGraphicDivider/ImageDataConverter.m
+++ b/KanColleGraphicDivider/ImageDataConverter.m
@@ -12,11 +12,13 @@ NSData *convertToPNGImagaData(id<ImageConvertible> image) {
1212
1313 NSData *tiffData = [image TIFFRepresentation];
1414 if(!tiffData) {
15+
1516 fprintf(stderr, "Can not create TIFF representation.\n");
1617 return nil;
1718 }
1819
1920 NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithData:tiffData];
21+
2022 return [rep representationUsingType:NSPNGFileType
2123 properties:@{}];
2224 }
--- a/KanColleGraphicDivider/ImageStore.m
+++ b/KanColleGraphicDivider/ImageStore.m
@@ -6,7 +6,6 @@
66 // Copyright © 2018年 Hori,Masaki. All rights reserved.
77 //
88
9-#include "KanColleGraphicDivider.h"
109 #import "ImageStore.h"
1110
1211 @interface ImageStore()
--- a/KanColleGraphicDivider/Information.m
+++ b/KanColleGraphicDivider/Information.m
@@ -8,7 +8,6 @@
88
99 #import "Information.h"
1010
11-
1211 @interface Information()
1312
1413 @property (copy, readwrite) NSURL *originalURL;
--- a/KanColleGraphicDivider/KanColleGraphicDivider.h
+++ /dev/null
@@ -1,21 +0,0 @@
1-//
2-// KanColleGraphicDivider.h
3-// KanColleGraphicDivider
4-//
5-// Created by Hori,Masaki on 2018/05/19.
6-// Copyright © 2018年 Hori,Masaki. All rights reserved.
7-//
8-
9-#ifndef KanColleGraphicDivider_h
10-#define KanColleGraphicDivider_h
11-
12-#include "SWFStructure.h"
13-
14-#if 0
15-#define printLog(...) printLogF( __VA_ARGS__)
16-void printLogF(const char *fmt, ...);
17-#else
18-#define printLog(...)
19-#endif
20-
21-#endif /* KanColleGraphicDivider_h */
--- a/KanColleGraphicDivider/main.m
+++ b/KanColleGraphicDivider/main.m
@@ -10,27 +10,9 @@
1010
1111 #include <getopt.h>
1212
13-#include "KanColleGraphicDivider.h"
14-
1513 #import "Information.h"
1614 #import "SWFDecodeProcessor.h"
1715
18-void printLogF(const char *fmt, ...) {
19- va_list ap;
20- va_start(ap, fmt);
21- vfprintf(stderr, fmt, ap);
22- va_end(ap);
23-}
24-
25-void printHex(const unsigned char *p) {
26- for(int i=0;i<1;i++) {
27- for(int j=0;j<16;j++) {
28- printLog("%02x ", *p++);
29- }
30- printLog("\n");
31- }
32-}
33-
3416 const char *toolName;
3517 const char *versionString = "1.0";
3618
@@ -39,8 +21,8 @@ const char *toolNameStr(const char *argv0)
3921 return [[[NSString stringWithFormat:@"%s", argv0] lastPathComponent] fileSystemRepresentation];
4022 }
4123
42-static void usage(int exitVal, FILE *fp)
43-{
24+static void usage(int exitVal, FILE *fp) {
25+
4426 fprintf(fp, "Usage: %s [OPTIONS] input-swf-file\n", toolName);
4527
4628 fprintf(fp, "\n");
@@ -56,8 +38,8 @@ static void usage(int exitVal, FILE *fp)
5638
5739 exit(exitVal);
5840 }
59-static void version()
60-{
41+static void version() {
42+
6143 printf("KanColleGraphicDivider %s\n", versionString);
6244 exit(EXIT_SUCCESS);
6345 }
@@ -85,6 +67,7 @@ int main(int argc, char * const *argv) {
8567 };
8668
8769 while((opt = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) {
70+
8871 switch(opt) {
8972 case 'o':
9073 oFilename = optarg;
@@ -105,39 +88,46 @@ int main(int argc, char * const *argv) {
10588 }
10689
10790 if(optind >= argc) {
91+
10892 usage(EXIT_FAILURE, stderr);
10993 }
11094
11195 if(oFilename) {
96+
11297 outputDir = [[NSString alloc] initWithUTF8String:oFilename];
11398 if( outputDir.length == 0 ) {
99+
114100 fprintf(stderr, "Output directory:%s can not convert file represendation.\n", oFilename);
115101 exit(EXIT_FAILURE);
116102 }
117103 NSFileManager *fm = [NSFileManager defaultManager];
118104 BOOL isDir = NO;
119105 if(![fm fileExistsAtPath:outputDir isDirectory:&isDir] || !isDir) {
106+
120107 fprintf(stderr, "Output directory:%s is not found or not directory.\n", outputDir.UTF8String);
121108 exit(EXIT_FAILURE);
122109 }
110+
123111 } else {
112+
124113 NSFileManager *fm = [NSFileManager defaultManager];
125114 outputDir = fm.currentDirectoryPath;
126115 }
127116
128117 if(charactorid) {
118+
129119 NSString *charactoridsString = [[NSString alloc] initWithUTF8String:charactorid];
130120 NSArray *ids = [charactoridsString componentsSeparatedByString:@","];
131121 if(ids.count != 0) {
132- charactorIds = ids;
133122
134- printLog("CaractorIDs is %s\n", [NSString stringWithFormat:@"%@", ids].fileSystemRepresentation);
123+ charactorIds = ids;
135124 }
136125 }
137126
138127 dispatch_group_t group = dispatch_group_create();
139128 dispatch_queue_t queue = dispatch_queue_create("Create image", DISPATCH_QUEUE_CONCURRENT);
140129 for(int filePos = optind; filePos < argc; filePos++) {
130+
141131 const char *filename = argv[filePos];
142132 Information *info = [Information new];
143133 info.outputDir = outputDir;
@@ -154,4 +144,3 @@ int main(int argc, char * const *argv) {
154144 }
155145 return 0;
156146 }
157-