• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonrubyphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

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


Commit MetaInfo

Révisionbe19272c3d9a4cb114c9de3e940cb9bb56546c8e (tree)
l'heure2018-05-22 22:41:53
Auteurmasakih <masakih@user...>
Commitermasakih

Message de Log

処理を統括するSWFDecodeProcessorを作成

Change Summary

Modification

--- a/KanColleGraphicDivider.xcodeproj/project.pbxproj
+++ b/KanColleGraphicDivider.xcodeproj/project.pbxproj
@@ -10,6 +10,7 @@
1010 F44C14BB1D84F07300ADE497 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F44C14BA1D84F07300ADE497 /* main.m */; };
1111 F44C14C41D85083E00ADE497 /* HMZlibData.m in Sources */ = {isa = PBXBuildFile; fileRef = F44C14C31D85083E00ADE497 /* HMZlibData.m */; };
1212 F48670A120B43D4B00DB9579 /* ImageDataConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = F48670A020B43D4B00DB9579 /* ImageDataConverter.m */; };
13+ F48670A420B4533400DB9579 /* SWFDecodeProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = F48670A320B4533400DB9579 /* SWFDecodeProcessor.m */; };
1314 F490569020B050D400CF637D /* BitsLossless2Decoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F490568F20B050D400CF637D /* BitsLossless2Decoder.m */; };
1415 F490569320B0512C00CF637D /* Information.m in Sources */ = {isa = PBXBuildFile; fileRef = F490569220B0512C00CF637D /* Information.m */; };
1516 F490569620B0568F00CF637D /* ImageStore.m in Sources */ = {isa = PBXBuildFile; fileRef = F490569520B0568F00CF637D /* ImageStore.m */; };
@@ -41,6 +42,8 @@
4142 F44C14C31D85083E00ADE497 /* HMZlibData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMZlibData.m; sourceTree = "<group>"; };
4243 F486709F20B43D4B00DB9579 /* ImageDataConverter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDataConverter.h; sourceTree = "<group>"; };
4344 F48670A020B43D4B00DB9579 /* ImageDataConverter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageDataConverter.m; sourceTree = "<group>"; };
45+ F48670A220B4533400DB9579 /* SWFDecodeProcessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWFDecodeProcessor.h; sourceTree = "<group>"; };
46+ F48670A320B4533400DB9579 /* SWFDecodeProcessor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWFDecodeProcessor.m; sourceTree = "<group>"; };
4447 F490568D20B04F5300CF637D /* ImageDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoder.h; sourceTree = "<group>"; };
4548 F490568E20B050D400CF637D /* BitsLossless2Decoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BitsLossless2Decoder.h; sourceTree = "<group>"; };
4649 F490568F20B050D400CF637D /* BitsLossless2Decoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BitsLossless2Decoder.m; sourceTree = "<group>"; };
@@ -101,6 +104,8 @@
101104 F486709D20B30A3100DB9579 /* Decoder */,
102105 F490569120B0512C00CF637D /* Information.h */,
103106 F490569220B0512C00CF637D /* Information.m */,
107+ F48670A220B4533400DB9579 /* SWFDecodeProcessor.h */,
108+ F48670A320B4533400DB9579 /* SWFDecodeProcessor.m */,
104109 F486709F20B43D4B00DB9579 /* ImageDataConverter.h */,
105110 F48670A020B43D4B00DB9579 /* ImageDataConverter.m */,
106111 F490569420B0568F00CF637D /* ImageStore.h */,
@@ -215,6 +220,7 @@
215220 F490569320B0512C00CF637D /* Information.m in Sources */,
216221 F44C14C41D85083E00ADE497 /* HMZlibData.m in Sources */,
217222 F49056A620B078DB00CF637D /* SwfData.m in Sources */,
223+ F48670A420B4533400DB9579 /* SWFDecodeProcessor.m in Sources */,
218224 );
219225 runOnlyForDeploymentPostprocessing = 0;
220226 };
--- a/KanColleGraphicDivider/Information.h
+++ b/KanColleGraphicDivider/Information.h
@@ -10,8 +10,8 @@
1010
1111 @interface Information: NSObject
1212
13-@property (readonly) NSURL *originalURL;
14-@property (copy, nonatomic, readonly) NSString *originalName;
13+@property (copy, readonly) NSURL *originalURL;
14+@property (copy, readonly) NSString *originalName;
1515
1616 @property (copy) NSString *outputDir;
1717 @property (copy) NSString *filename;
--- a/KanColleGraphicDivider/Information.m
+++ b/KanColleGraphicDivider/Information.m
@@ -11,9 +11,9 @@
1111
1212 @interface Information()
1313
14-@property (readwrite) NSURL *originalURL;
14+@property (copy, readwrite) NSURL *originalURL;
1515
16-@property (copy, nonatomic, readwrite) NSString *originalName;
16+@property (copy, readwrite) NSString *originalName;
1717
1818 @end
1919
@@ -26,6 +26,7 @@
2626 if(self.charctorIds.count == 0) return false;
2727
2828 for(NSString *charID in self.charctorIds) {
29+
2930 if(charID.integerValue == chractorid) return false;
3031 }
3132 return true;
@@ -38,6 +39,7 @@
3839 NSString *filePath = [filename copy];
3940
4041 if(![filePath hasPrefix:@"/"]) {
42+
4143 NSFileManager *fm = [NSFileManager defaultManager];
4244 filePath = [fm.currentDirectoryPath stringByAppendingPathComponent:filePath];
4345 }
--- /dev/null
+++ b/KanColleGraphicDivider/SWFDecodeProcessor.h
@@ -0,0 +1,19 @@
1+//
2+// SWFDecodeProcessor.h
3+// KanColleGraphicDivider
4+//
5+// Created by Hori,Masaki on 2018/05/22.
6+// Copyright © 2018年 Hori,Masaki. All rights reserved.
7+//
8+
9+#import <Foundation/Foundation.h>
10+
11+#import "Information.h"
12+
13+@interface SWFDecodeProcessor : NSObject
14+
15++ (instancetype)swfDecodeProcessorWithInformation:(Information *)infotmation;
16+
17+- (void)process;
18+
19+@end
--- /dev/null
+++ b/KanColleGraphicDivider/SWFDecodeProcessor.m
@@ -0,0 +1,60 @@
1+//
2+// SWFDecodeProcessor.m
3+// KanColleGraphicDivider
4+//
5+// Created by Hori,Masaki on 2018/05/22.
6+// Copyright © 2018年 Hori,Masaki. All rights reserved.
7+//
8+
9+#import "SWFDecodeProcessor.h"
10+
11+#import "SwfData.h"
12+#import "ImageStore.h"
13+
14+@interface SWFDecodeProcessor()
15+
16+@property Information *information;
17+
18+@end
19+
20+@implementation SWFDecodeProcessor
21+
22++ (instancetype)swfDecodeProcessorWithInformation:(Information *)infotmation {
23+
24+ return [[self alloc] initWithInformation:infotmation];
25+}
26+
27+- (instancetype)initWithInformation:(Information *)information {
28+
29+ self = [super init];
30+ if( self ) {
31+
32+ self.information = information;
33+ }
34+
35+ return self;
36+}
37+
38+- (void)process {
39+
40+ NSData *data = [NSData dataWithContentsOfURL:self.information.originalURL];
41+ if(!data) {
42+ fprintf(stderr, "Can not open %s.\n", self.information.filename.UTF8String);
43+ return;
44+ }
45+
46+ SwfData *swf = [SwfData dataWithData:data];
47+ SwfContent *content = swf.firstContent;
48+
49+ ImageStore *store = [ImageStore imageStoreWithInformation:self.information];
50+
51+ while( content ) {
52+
53+ SwfContent *aContent = content;
54+ content = aContent.next;
55+
56+ [store store:content.decoder];
57+ }
58+}
59+
60+@end
--- a/KanColleGraphicDivider/main.m
+++ b/KanColleGraphicDivider/main.m
@@ -13,9 +13,7 @@
1313 #include "KanColleGraphicDivider.h"
1414
1515 #import "Information.h"
16-#import "ImageStore.h"
17-
18-#import "SwfData.h"
16+#import "SWFDecodeProcessor.h"
1917
2018 void printLogF(const char *fmt, ...) {
2119 va_list ap;
@@ -64,28 +62,6 @@ static void version()
6462 exit(EXIT_SUCCESS);
6563 }
6664
67-void extractImagesFromSWFFile(Information *info) {
68-
69- NSData *data = [NSData dataWithContentsOfURL:info.originalURL];
70- if(!data) {
71- fprintf(stderr, "Can not open %s.\n", info.filename.UTF8String);
72- return;
73- }
74-
75- SwfData *swf = [SwfData dataWithData:data];
76- SwfContent *content = swf.firstContent;
77-
78- ImageStore *store = [ImageStore imageStoreWithInformation:info];
79-
80- while( content ) {
81-
82- SwfContent *aContent = content;
83- content = aContent.next;
84-
85- [store store:content.decoder];
86- }
87-}
88-
8965 int main(int argc, char * const *argv) {
9066
9167 NSString *outputDir = nil;
@@ -169,7 +145,9 @@ int main(int argc, char * const *argv) {
169145 info.filename = [[NSString alloc] initWithUTF8String:filename];
170146
171147 dispatch_group_async(group, queue, ^{
172- extractImagesFromSWFFile(info);
148+
149+ SWFDecodeProcessor *processor = [SWFDecodeProcessor swfDecodeProcessorWithInformation:info];
150+ [processor process];
173151 });
174152 }
175153 dispatch_group_wait(group, DISPATCH_TIME_FOREVER);