Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved tile cutting into an NSOperation to leverage all computing core…

…s. Still somewhat inefficient for large images, but should be faster.
  • Loading branch information...
commit 1c5e66f371b19ed62c3121d21fbda842771207d5 1 parent 7205fa4
jlamarche authored
View
BIN  .DS_Store
Binary file not shown
View
17 NSInvocation-MCUtilities.h
@@ -0,0 +1,17 @@
+//
+// NSInvocation-MCUtilities.h
+// Visioneer
+//
+// Created by jeff on 7/26/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSInvocation(MCUtilities)
+-(void)invokeOnMainThreadWaitUntilDone:(BOOL)wait;
++(NSInvocation*)invocationWithTarget:(id)target
+ selector:(SEL)aSelector
+ retainArguments:(BOOL)retainArguments, ...;
+@end
View
47 NSInvocation-MCUtilities.m
@@ -0,0 +1,47 @@
+//
+// NSInvocation-MCUtilities.m
+// Visioneer
+//
+
+//
+// Source: http://blog.jayway.com/2010/03/30/performing-any-selector-on-the-main-thread/
+//
+#import "NSInvocation-MCUtilities.h"
+
+
+@implementation NSInvocation(MCUtilities)
+-(void)invokeOnMainThreadWaitUntilDone:(BOOL)wait
+{
+ [self performSelectorOnMainThread:@selector(invoke)
+ withObject:nil
+ waitUntilDone:wait];
+}
++(NSInvocation*)invocationWithTarget:(id)target
+ selector:(SEL)aSelector
+ retainArguments:(BOOL)retainArguments, ...
+{
+ va_list ap;
+ va_start(ap, retainArguments);
+ char* args = (char*)ap;
+ NSMethodSignature* signature = [target methodSignatureForSelector:aSelector];
+ NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
+ if (retainArguments) {
+ [invocation retainArguments];
+ }
+ [invocation setTarget:target];
+ [invocation setSelector:aSelector];
+ for (int index = 2; index < [signature numberOfArguments]; index++) {
+ const char *type = [signature getArgumentTypeAtIndex:index];
+ NSUInteger size, align;
+ NSGetSizeAndAlignment(type, &size, &align);
+ NSUInteger mod = (NSUInteger)args % align;
+ if (mod != 0) {
+ args += (align - mod);
+ }
+ [invocation setArgument:args atIndex:index];
+ args += size;
+ }
+ va_end(ap);
+ return invocation;
+}
+@end
View
255 Tile Cutter.xcodeproj/jeff.pbxuser
@@ -9,7 +9,7 @@
};
1F15EA18125E826600B32D97 /* NSImage-Tile.h */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {1104, 604}}";
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 941}}";
sepNavSelRange = "{314, 106}";
sepNavVisRange = "{0, 426}";
};
@@ -31,11 +31,11 @@
delayBeforeContinue = 0;
fileReference = 1F15EA19125E826600B32D97 /* NSImage-Tile.m */;
functionName = "-subImageWithTileWidth:tileHeight:column:row:";
- hitCount = 1;
+ hitCount = 0;
ignoreCount = 0;
lineNumber = 51;
location = "Tile Cutter";
- modificationTime = 308269079.3798209;
+ modificationTime = 310152512.711327;
originalNumberOfMultipleMatches = 1;
state = 1;
};
@@ -49,16 +49,6 @@
vrLen = 2149;
vrLoc = 793;
};
- 1F5BA908125F647E0090EDC2 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1F15EA18125E826600B32D97 /* NSImage-Tile.h */;
- name = "NSImage-Tile.h: 14";
- rLen = 106;
- rLoc = 314;
- rType = 0;
- vrLen = 426;
- vrLoc = 0;
- };
1F5BAC84125F9D920090EDC2 /* PBXBookmark */ = {
isa = PBXBookmark;
fRef = 1F5BAC71125F9BAC0090EDC2 /* Tile Cutter.icns */;
@@ -73,16 +63,6 @@
vrLen = 673;
vrLoc = 0;
};
- 1F5BACA2125F9E920090EDC2 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 256AC3D80F4B6AC300CF3369 /* Tile_CutterAppDelegate.h */;
- name = "Tile_CutterAppDelegate.h: 21";
- rLen = 0;
- rLoc = 598;
- rType = 0;
- vrLen = 853;
- vrLoc = 0;
- };
1F5BACB8125FA0BC0090EDC2 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 1F8CA17A125E531300588223 /* TileCutterView.m */;
@@ -216,16 +196,6 @@
sepNavVisRange = "{2313, 1550}";
};
};
- 1FAC44AD126E59EA00A78D4F /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */;
- name = "Tile_CutterAppDelegate.m: 25";
- rLen = 0;
- rLoc = 594;
- rType = 0;
- vrLen = 1457;
- vrLoc = 146;
- };
1FAC44AE126E59EA00A78D4F /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 089C165DFE840E0CC02AAC07 /* English */;
@@ -236,42 +206,187 @@
vrLen = 45;
vrLoc = 0;
};
- 1FAC44B0126E59EA00A78D4F /* PlistBookmark */ = {
+ 1FFB993F127C847100BE5A73 /* TileOperation.h */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 648}}";
+ sepNavSelRange = "{228, 137}";
+ sepNavVisRange = "{0, 684}";
+ };
+ };
+ 1FFB9940127C847100BE5A73 /* TileOperation.m */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 913}}";
+ sepNavSelRange = "{2308, 0}";
+ sepNavVisRange = "{835, 1766}";
+ sepNavWindowFrame = "{{15, 4}, {1480, 1054}}";
+ };
+ };
+ 1FFB9955127C86A600BE5A73 /* PlistBookmark */ = {
isa = PlistBookmark;
fRef = 8D1107310486CEB800E47090 /* Tile_Cutter-Info.plist */;
fallbackIsa = PBXBookmark;
isK = 0;
kPath = (
- CFBundleSignature,
+ CFBundleInfoDictionaryVersion,
);
name = "/Users/jeff/dev/Tile Cutter/Tile_Cutter-Info.plist";
rLen = 0;
- rLoc = 9223372036854775807;
+ rLoc = 9223372036854775808;
};
- 1FAC44B5126E5AC400A78D4F /* PlistBookmark */ = {
- isa = PlistBookmark;
- fRef = 8D1107310486CEB800E47090 /* Tile_Cutter-Info.plist */;
- fallbackIsa = PBXBookmark;
- isK = 0;
- kPath = (
- CFBundleSignature,
+ 1FFB9956127C86A600BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1F15EA18125E826600B32D97 /* NSImage-Tile.h */;
+ name = "NSImage-Tile.h: 14";
+ rLen = 106;
+ rLoc = 314;
+ rType = 0;
+ vrLen = 426;
+ vrLoc = 0;
+ };
+ 1FFB9977127C874900BE5A73 /* NSInvocation-MCUtilities.h */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 654}}";
+ sepNavSelRange = "{0, 0}";
+ sepNavVisRange = "{0, 440}";
+ };
+ };
+ 1FFB9978127C874900BE5A73 /* NSInvocation-MCUtilities.m */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 654}}";
+ sepNavSelRange = "{909, 0}";
+ sepNavVisRange = "{0, 1459}";
+ };
+ };
+ 1FFB997B127C87C000BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB9977127C874900BE5A73 /* NSInvocation-MCUtilities.h */;
+ name = "NSInvocation-MCUtilities.h: 1";
+ rLen = 0;
+ rLoc = 0;
+ rType = 0;
+ vrLen = 440;
+ vrLoc = 0;
+ };
+ 1FFB997C127C87C000BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB9978127C874900BE5A73 /* NSInvocation-MCUtilities.m */;
+ name = "NSInvocation-MCUtilities.m: 30";
+ rLen = 0;
+ rLoc = 909;
+ rType = 0;
+ vrLen = 1459;
+ vrLoc = 0;
+ };
+ 1FFB99BC127C8D2000BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB993F127C847100BE5A73 /* TileOperation.h */;
+ name = "TileOperation.h: 15";
+ rLen = 137;
+ rLoc = 228;
+ rType = 0;
+ vrLen = 684;
+ vrLoc = 0;
+ };
+ 1FFB99BD127C8D2000BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB9940127C847100BE5A73 /* TileOperation.m */;
+ name = "TileOperation.m: 64";
+ rLen = 0;
+ rLoc = 2308;
+ rType = 0;
+ vrLen = 1744;
+ vrLoc = 857;
+ };
+ 1FFB99BE127C8D2000BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 256AC3D80F4B6AC300CF3369 /* Tile_CutterAppDelegate.h */;
+ name = "Tile_CutterAppDelegate.h: 13";
+ rLen = 0;
+ rLoc = 310;
+ rType = 0;
+ vrLen = 958;
+ vrLoc = 0;
+ };
+ 1FFB99C4127C8D3800BE5A73 /* Tile_CutterAppDelegate.m:168 */ = {
+ isa = PBXFileBreakpoint;
+ actions = (
);
- name = "/Users/jeff/dev/Tile Cutter/Tile_Cutter-Info.plist";
+ breakpointStyle = 0;
+ continueAfterActions = 0;
+ countType = 0;
+ delayBeforeContinue = 0;
+ fileReference = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */;
+ functionName = "-operationDidFinishSuccessfully:";
+ hitCount = 0;
+ ignoreCount = 0;
+ lineNumber = 168;
+ location = "Tile Cutter";
+ modificationTime = 310152512.760041;
+ originalNumberOfMultipleMatches = 1;
+ state = 1;
+ };
+ 1FFB99F9127C8E7C00BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */;
+ name = "Tile_CutterAppDelegate.m: 177";
+ rLen = 0;
+ rLoc = 5395;
+ rType = 0;
+ vrLen = 711;
+ vrLoc = 5016;
+ };
+ 1FFB99FB127C8E8800BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */;
+ name = "Tile_CutterAppDelegate.m: 177";
+ rLen = 0;
+ rLoc = 5395;
+ rType = 0;
+ vrLen = 1822;
+ vrLoc = 4413;
+ };
+ 1FFB9A05127C8F1900BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */;
+ name = "Tile_CutterAppDelegate.m: 177";
rLen = 0;
- rLoc = 9223372036854775807;
+ rLoc = 5395;
+ rType = 0;
+ vrLen = 1824;
+ vrLoc = 4411;
+ };
+ 1FFB9A06127C8F1900BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB993F127C847100BE5A73 /* TileOperation.h */;
+ name = "TileOperation.h: 15";
+ rLen = 137;
+ rLoc = 228;
+ rType = 0;
+ vrLen = 684;
+ vrLoc = 0;
+ };
+ 1FFB9A07127C8F1900BE5A73 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 1FFB9940127C847100BE5A73 /* TileOperation.m */;
+ name = "TileOperation.m: 64";
+ rLen = 0;
+ rLoc = 2308;
+ rType = 0;
+ vrLen = 1766;
+ vrLoc = 835;
};
256AC3D80F4B6AC300CF3369 /* Tile_CutterAppDelegate.h */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {1311, 308}}";
- sepNavSelRange = "{598, 0}";
- sepNavVisRange = "{145, 708}";
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 606}}";
+ sepNavSelRange = "{310, 0}";
+ sepNavVisRange = "{0, 958}";
};
};
256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {1104, 1804}}";
- sepNavSelRange = "{594, 0}";
- sepNavVisRange = "{146, 1457}";
+ sepNavIntBoundsRect = "{{0, 0}, {1652, 2156}}";
+ sepNavSelRange = "{5395, 0}";
+ sepNavVisRange = "{4411, 1824}";
};
};
29B97313FDCFA39411CA2CEA /* Project object */ = {
@@ -284,6 +399,7 @@
);
breakpoints = (
1F373C88125FD001007ED8A4 /* NSImage-Tile.m:51 */,
+ 1FFB99C4127C8D3800BE5A73 /* Tile_CutterAppDelegate.m:168 */,
);
codeSenseManager = 1F8CA174125E528D00588223 /* Code sense */;
executables = (
@@ -333,7 +449,7 @@
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
- 926,
+ 1474,
20,
48,
43,
@@ -372,22 +488,29 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
- PBXPerProjectTemplateStateSaveDate = 309221828;
- PBXWorkspaceStateSaveDate = 309221828;
+ PBXPerProjectTemplateStateSaveDate = 310152968;
+ PBXWorkspaceStateSaveDate = 310152968;
};
perUserProjectItems = {
- 1F564186126E010C0031625B /* PBXTextBookmark */ = 1F564186126E010C0031625B /* PBXTextBookmark */;
- 1F5BA908125F647E0090EDC2 /* PBXTextBookmark */ = 1F5BA908125F647E0090EDC2 /* PBXTextBookmark */;
- 1F5BAC84125F9D920090EDC2 /* PBXBookmark */ = 1F5BAC84125F9D920090EDC2 /* PBXBookmark */;
- 1F5BAC91125F9E3C0090EDC2 /* PBXTextBookmark */ = 1F5BAC91125F9E3C0090EDC2 /* PBXTextBookmark */;
- 1F5BACA2125F9E920090EDC2 /* PBXTextBookmark */ = 1F5BACA2125F9E920090EDC2 /* PBXTextBookmark */;
- 1F5BACB8125FA0BC0090EDC2 /* PBXTextBookmark */ = 1F5BACB8125FA0BC0090EDC2 /* PBXTextBookmark */;
- 1F5BAD02125FA4B00090EDC2 /* PBXTextBookmark */ = 1F5BAD02125FA4B00090EDC2 /* PBXTextBookmark */;
- 1F80E5A2125E9CCC00673317 /* PBXTextBookmark */ = 1F80E5A2125E9CCC00673317 /* PBXTextBookmark */;
- 1FAC44AD126E59EA00A78D4F /* PBXTextBookmark */ = 1FAC44AD126E59EA00A78D4F /* PBXTextBookmark */;
- 1FAC44AE126E59EA00A78D4F /* PBXTextBookmark */ = 1FAC44AE126E59EA00A78D4F /* PBXTextBookmark */;
- 1FAC44B0126E59EA00A78D4F /* PlistBookmark */ = 1FAC44B0126E59EA00A78D4F /* PlistBookmark */;
- 1FAC44B5126E5AC400A78D4F /* PlistBookmark */ = 1FAC44B5126E5AC400A78D4F /* PlistBookmark */;
+ 1F564186126E010C0031625B = 1F564186126E010C0031625B /* PBXTextBookmark */;
+ 1F5BAC84125F9D920090EDC2 = 1F5BAC84125F9D920090EDC2 /* PBXBookmark */;
+ 1F5BAC91125F9E3C0090EDC2 = 1F5BAC91125F9E3C0090EDC2 /* PBXTextBookmark */;
+ 1F5BACB8125FA0BC0090EDC2 = 1F5BACB8125FA0BC0090EDC2 /* PBXTextBookmark */;
+ 1F5BAD02125FA4B00090EDC2 = 1F5BAD02125FA4B00090EDC2 /* PBXTextBookmark */;
+ 1F80E5A2125E9CCC00673317 = 1F80E5A2125E9CCC00673317 /* PBXTextBookmark */;
+ 1FAC44AE126E59EA00A78D4F = 1FAC44AE126E59EA00A78D4F /* PBXTextBookmark */;
+ 1FFB9955127C86A600BE5A73 = 1FFB9955127C86A600BE5A73 /* PlistBookmark */;
+ 1FFB9956127C86A600BE5A73 = 1FFB9956127C86A600BE5A73 /* PBXTextBookmark */;
+ 1FFB997B127C87C000BE5A73 = 1FFB997B127C87C000BE5A73 /* PBXTextBookmark */;
+ 1FFB997C127C87C000BE5A73 = 1FFB997C127C87C000BE5A73 /* PBXTextBookmark */;
+ 1FFB99BC127C8D2000BE5A73 = 1FFB99BC127C8D2000BE5A73 /* PBXTextBookmark */;
+ 1FFB99BD127C8D2000BE5A73 = 1FFB99BD127C8D2000BE5A73 /* PBXTextBookmark */;
+ 1FFB99BE127C8D2000BE5A73 = 1FFB99BE127C8D2000BE5A73 /* PBXTextBookmark */;
+ 1FFB99F9127C8E7C00BE5A73 = 1FFB99F9127C8E7C00BE5A73 /* PBXTextBookmark */;
+ 1FFB99FB127C8E8800BE5A73 = 1FFB99FB127C8E8800BE5A73 /* PBXTextBookmark */;
+ 1FFB9A05127C8F1900BE5A73 /* PBXTextBookmark */ = 1FFB9A05127C8F1900BE5A73 /* PBXTextBookmark */;
+ 1FFB9A06127C8F1900BE5A73 /* PBXTextBookmark */ = 1FFB9A06127C8F1900BE5A73 /* PBXTextBookmark */;
+ 1FFB9A07127C8F1900BE5A73 /* PBXTextBookmark */ = 1FFB9A07127C8F1900BE5A73 /* PBXTextBookmark */;
};
sourceControlManager = 1F8CA173125E528D00588223 /* Source Control */;
userBuildSettings = {
View
92 Tile Cutter.xcodeproj/jeff.perspectivev3
@@ -219,8 +219,8 @@
<array/>
<key>PerspectiveWidths</key>
<array>
- <integer>1372</integer>
- <integer>1372</integer>
+ <integer>1920</integer>
+ <integer>1920</integer>
</array>
<key>Perspectives</key>
<array>
@@ -252,6 +252,8 @@
<key>Layout</key>
<array>
<dict>
+ <key>BecomeActive</key>
+ <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXBottomSmartGroupGIDs</key>
@@ -302,11 +304,13 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
+ <integer>13</integer>
+ <integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
- <string>{{0, 0}, {185, 810}}</string>
+ <string>{{0, 0}, {185, 945}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@@ -316,14 +320,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {202, 828}}</string>
+ <string>{{0, 0}, {202, 963}}</string>
<key>GroupTreeTableConfiguration</key>
<array>
<string>MainColumn</string>
<real>185</real>
</array>
<key>RubberWindowFrame</key>
- <string>362 96 1372 869 0 0 1920 1058 </string>
+ <string>0 54 1920 1004 0 0 1920 1058 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@@ -339,7 +343,7 @@
<key>PBXProjectModuleGUID</key>
<string>1F8CA1B5125E590E00588223</string>
<key>PBXProjectModuleLabel</key>
- <string>Tile_Cutter-Info.plist</string>
+ <string>TileOperation.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@@ -347,24 +351,28 @@
<key>PBXProjectModuleGUID</key>
<string>1F8CA1B6125E590E00588223</string>
<key>PBXProjectModuleLabel</key>
- <string>Tile_Cutter-Info.plist</string>
+ <string>TileOperation.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
- <string>1FAC44B5126E5AC400A78D4F</string>
+ <string>1FFB9A07127C8F1900BE5A73</string>
<key>history</key>
<array>
<string>1F80E5A2125E9CCC00673317</string>
- <string>1F5BA908125F647E0090EDC2</string>
<string>1F5BAC84125F9D920090EDC2</string>
<string>1F5BAC91125F9E3C0090EDC2</string>
- <string>1F5BACA2125F9E920090EDC2</string>
<string>1F5BACB8125FA0BC0090EDC2</string>
<string>1F5BAD02125FA4B00090EDC2</string>
<string>1F564186126E010C0031625B</string>
- <string>1FAC44AD126E59EA00A78D4F</string>
<string>1FAC44AE126E59EA00A78D4F</string>
- <string>1FAC44B0126E59EA00A78D4F</string>
+ <string>1FFB9955127C86A600BE5A73</string>
+ <string>1FFB9956127C86A600BE5A73</string>
+ <string>1FFB997B127C87C000BE5A73</string>
+ <string>1FFB997C127C87C000BE5A73</string>
+ <string>1FFB99BE127C8D2000BE5A73</string>
+ <string>1FFB9A05127C8F1900BE5A73</string>
+ <string>1FFB9A06127C8F1900BE5A73</string>
+ <string>1FFB99BD127C8D2000BE5A73</string>
</array>
</dict>
<key>SplitCount</key>
@@ -378,18 +386,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {1165, 570}}</string>
+ <string>{{0, 0}, {1713, 665}}</string>
<key>RubberWindowFrame</key>
- <string>362 96 1372 869 0 0 1920 1058 </string>
+ <string>0 54 1920 1004 0 0 1920 1058 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
- <string>570pt</string>
+ <string>665pt</string>
</dict>
<dict>
<key>Proportion</key>
- <string>253pt</string>
+ <string>293pt</string>
<key>Tabs</key>
<array>
<dict>
@@ -403,7 +411,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{10, 27}, {1165, 226}}</string>
+ <string>{{10, 27}, {1713, 266}}</string>
+ <key>RubberWindowFrame</key>
+ <string>0 54 1920 1004 0 0 1920 1058 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@@ -457,9 +467,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{10, 27}, {1165, 226}}</string>
- <key>RubberWindowFrame</key>
- <string>362 96 1372 869 0 0 1920 1058 </string>
+ <string>{{10, 27}, {1713, 260}}</string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
@@ -468,7 +476,7 @@
</dict>
</array>
<key>Proportion</key>
- <string>1165pt</string>
+ <string>1713pt</string>
</dict>
</array>
<key>Name</key>
@@ -487,11 +495,11 @@
</array>
<key>TableOfContents</key>
<array>
- <string>1FAC44B2126E59F700A78D4F</string>
+ <string>1FFB9A08127C8F1900BE5A73</string>
<string>1CA23ED40692098700951B8B</string>
- <string>1FAC44B3126E59F700A78D4F</string>
+ <string>1FFB9A09127C8F1900BE5A73</string>
<string>1F8CA1B5125E590E00588223</string>
- <string>1FAC44B4126E59F700A78D4F</string>
+ <string>1FFB9A0A127C8F1900BE5A73</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@@ -542,12 +550,12 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {1372, 357}}</string>
+ <string>{{0, 0}, {1920, 416}}</string>
</dict>
<key>Module</key>
<string>PBXDebugCLIModule</string>
<key>Proportion</key>
- <string>357pt</string>
+ <string>416pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@@ -566,8 +574,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {670, 226}}</string>
- <string>{{670, 0}, {702, 226}}</string>
+ <string>{{0, 0}, {938, 263}}</string>
+ <string>{{938, 0}, {982, 263}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@@ -582,8 +590,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {1372, 226}}</string>
- <string>{{0, 226}, {1372, 240}}</string>
+ <string>{{0, 0}, {1920, 263}}</string>
+ <string>{{0, 263}, {1920, 279}}</string>
</array>
</dict>
</dict>
@@ -603,7 +611,7 @@
<key>DebugSTDIOWindowFrame</key>
<string>{{200, 200}, {500, 300}}</string>
<key>Frame</key>
- <string>{{0, 362}, {1372, 466}}</string>
+ <string>{{0, 421}, {1920, 542}}</string>
<key>PBXDebugSessionStackFrameViewKey</key>
<dict>
<key>DebugVariablesTableConfiguration</key>
@@ -613,16 +621,16 @@
<string>Value</string>
<real>85</real>
<string>Summary</string>
- <real>472</real>
+ <real>752</real>
</array>
<key>Frame</key>
- <string>{{670, 0}, {702, 226}}</string>
+ <string>{{938, 0}, {982, 263}}</string>
</dict>
</dict>
<key>Module</key>
<string>PBXDebugSessionModule</string>
<key>Proportion</key>
- <string>466pt</string>
+ <string>542pt</string>
</dict>
</array>
<key>Name</key>
@@ -640,14 +648,14 @@
</array>
<key>TableOfContents</key>
<array>
- <string>1F56418F126E02560031625B</string>
+ <string>1FFB9969127C870A00BE5A73</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
- <string>1F564190126E02560031625B</string>
- <string>1F564191126E02560031625B</string>
- <string>1F564192126E02560031625B</string>
- <string>1F564193126E02560031625B</string>
- <string>1F8CA1B5125E590E00588223</string>
+ <string>1FFB996A127C870A00BE5A73</string>
+ <string>1FFB996B127C870A00BE5A73</string>
+ <string>1FFB996C127C870A00BE5A73</string>
+ <string>1FFB996D127C870A00BE5A73</string>
+ <string>1FFB996E127C870A00BE5A73</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
@@ -664,7 +672,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
- <real>309222084.64321101</real>
+ <real>310152985.53588802</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@@ -684,7 +692,7 @@
<string>/Users/jeff/dev/Tile Cutter/Tile Cutter.xcodeproj</string>
</array>
<key>WindowString</key>
- <string>362 96 1372 869 0 0 1920 1058 </string>
+ <string>0 54 1920 1004 0 0 1920 1058 </string>
<key>WindowToolsV3</key>
<array>
<dict>
View
13 Tile Cutter.xcodeproj/project.pbxproj
@@ -13,6 +13,8 @@
1F5BACFD125FA41E0090EDC2 /* NSUserDefaults-MCColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F5BACFC125FA41E0090EDC2 /* NSUserDefaults-MCColor.m */; };
1F8CA17B125E531300588223 /* TileCutterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8CA17A125E531300588223 /* TileCutterView.m */; };
1F8CA2B8125E6A8900588223 /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F8CA2B7125E6A8900588223 /* image.png */; };
+ 1FFB9941127C847100BE5A73 /* TileOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FFB9940127C847100BE5A73 /* TileOperation.m */; };
+ 1FFB9979127C874900BE5A73 /* NSInvocation-MCUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FFB9978127C874900BE5A73 /* NSInvocation-MCUtilities.m */; };
256AC3DA0F4B6AC300CF3369 /* Tile_CutterAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -32,6 +34,10 @@
1F8CA179125E531300588223 /* TileCutterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileCutterView.h; sourceTree = "<group>"; };
1F8CA17A125E531300588223 /* TileCutterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TileCutterView.m; sourceTree = "<group>"; };
1F8CA2B7125E6A8900588223 /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = "<group>"; };
+ 1FFB993F127C847100BE5A73 /* TileOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileOperation.h; sourceTree = "<group>"; };
+ 1FFB9940127C847100BE5A73 /* TileOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TileOperation.m; sourceTree = "<group>"; };
+ 1FFB9977127C874900BE5A73 /* NSInvocation-MCUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSInvocation-MCUtilities.h"; sourceTree = "<group>"; };
+ 1FFB9978127C874900BE5A73 /* NSInvocation-MCUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation-MCUtilities.m"; sourceTree = "<group>"; };
256AC3D80F4B6AC300CF3369 /* Tile_CutterAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tile_CutterAppDelegate.h; sourceTree = "<group>"; };
256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tile_CutterAppDelegate.m; sourceTree = "<group>"; };
256AC3F00F4B6AF500CF3369 /* Tile_Cutter_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tile_Cutter_Prefix.pch; sourceTree = "<group>"; };
@@ -57,6 +63,8 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
+ 1FFB9977127C874900BE5A73 /* NSInvocation-MCUtilities.h */,
+ 1FFB9978127C874900BE5A73 /* NSInvocation-MCUtilities.m */,
256AC3D80F4B6AC300CF3369 /* Tile_CutterAppDelegate.h */,
256AC3D90F4B6AC300CF3369 /* Tile_CutterAppDelegate.m */,
1F8CA179125E531300588223 /* TileCutterView.h */,
@@ -65,6 +73,8 @@
1F15EA19125E826600B32D97 /* NSImage-Tile.m */,
1F5BACFB125FA41E0090EDC2 /* NSUserDefaults-MCColor.h */,
1F5BACFC125FA41E0090EDC2 /* NSUserDefaults-MCColor.m */,
+ 1FFB993F127C847100BE5A73 /* TileOperation.h */,
+ 1FFB9940127C847100BE5A73 /* TileOperation.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -206,6 +216,8 @@
1F8CA17B125E531300588223 /* TileCutterView.m in Sources */,
1F15EAF9125E8ED200B32D97 /* NSImage-Tile.m in Sources */,
1F5BACFD125FA41E0090EDC2 /* NSUserDefaults-MCColor.m in Sources */,
+ 1FFB9941127C847100BE5A73 /* TileOperation.m in Sources */,
+ 1FFB9979127C874900BE5A73 /* NSInvocation-MCUtilities.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -297,6 +309,7 @@
);
PREBINDING = NO;
SDKROOT = macosx10.6;
+ VALID_ARCHS = "i386 x86_64";
};
name = Release;
};
View
31 TileOperation.h
@@ -0,0 +1,31 @@
+//
+// TileOperation.h
+// Tile Cutter
+//
+// Created by jeff on 10/30/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@class TileOperation;
+
+@protocol TileOperationDelegate
+@optional
+- (void)operationDidFinishSuccessfully:(TileOperation *)op;
+- (void)operation:(TileOperation *)op didFailWithMessage:(NSString *)message;
+@end
+
+
+@interface TileOperation : NSOperation
+{
+
+}
+@property (assign) NSObject <TileOperationDelegate> *delegate;
+@property (retain) NSImage *image;
+@property NSUInteger column;
+@property NSUInteger row;
+@property (retain) NSString *baseFilename;
+@property NSUInteger tileHeight;
+@property NSUInteger tileWidth;
+@end
View
82 TileOperation.m
@@ -0,0 +1,82 @@
+//
+// TileOperation.m
+// Tile Cutter
+//
+// Created by jeff on 10/30/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "TileOperation.h"
+#import "NSImage-Tile.h"
+#import "NSInvocation-MCUtilities.h"
+
+@implementation TileOperation
+@synthesize delegate, image, column, row, baseFilename, tileHeight, tileWidth;
+#pragma mark -
+- (void)informDelegateOfError:(NSString *)message
+{
+
+ if ([delegate respondsToSelector:@selector(operation:didFailWithMessage:)])
+ {
+ NSInvocation *invocation = [NSInvocation invocationWithTarget:delegate
+ selector:@selector(operation:didFailWithMessage:)
+ retainArguments:YES, self, message];
+ [invocation invokeOnMainThreadWaitUntilDone:YES];
+ }
+}
+- (void)main
+{
+ @try
+ {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSImage *subImage = [image subImageWithTileWidth:(float)tileWidth tileHeight:(float)tileHeight column:column row:row];
+
+ if (subImage == nil)
+ {
+ [self informDelegateOfError:NSLocalizedString(@"Error creating tile", @"")];
+ goto finish;
+ }
+
+ NSArray * representations = [subImage representations];
+
+ if ([self isCancelled])
+ goto finish;
+
+ NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations
+ usingType:NSJPEGFileType properties:nil];
+
+ if (bitmapData == nil)
+ {
+ [self informDelegateOfError:NSLocalizedString(@"Error retrieving bitmap data from result", @"")];
+ goto finish;
+ }
+
+
+ if ([self isCancelled])
+ goto finish;
+
+ NSString *outPath = [NSString stringWithFormat:@"%@_%d_%d.jpg", baseFilename, row, column];
+ [bitmapData writeToFile:outPath atomically:YES];
+
+ if ([delegate respondsToSelector:@selector(operationDidFinishSuccessfully:)])
+ [delegate performSelectorOnMainThread:@selector(operationDidFinishSuccessfully:)
+ withObject:self
+ waitUntilDone:NO];
+ finish:
+ [pool drain];
+ }
+ @catch (NSException * e)
+ {
+ NSLog(@"Exception: %@", e);
+ }
+}
+
+- (void)dealloc
+{
+ delegate = nil;
+ [image release], image = nil;
+ [baseFilename release], baseFilename = nil;
+
+ [super dealloc];
+}
+@end
View
2  Tile_Cutter-Info.plist
@@ -39,7 +39,7 @@
<key>CFBundleIconFile</key>
<string>Tile Cutter.icns</string>
<key>CFBundleIdentifier</key>
- <string>com.naked.${PRODUCT_NAME:rfc1034identifier}</string>
+ <string>com.naked.TileCutter</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
View
5 Tile_CutterAppDelegate.h
@@ -7,9 +7,10 @@
//
#import <Cocoa/Cocoa.h>
+#import "TileOperation.h"
@class TileCutterView;
-@interface Tile_CutterAppDelegate : NSObject <NSApplicationDelegate>
+@interface Tile_CutterAppDelegate : NSObject <NSApplicationDelegate, TileOperationDelegate>
{
}
@@ -22,6 +23,8 @@
@property (retain) IBOutlet NSWindow *progressWindow;
@property (retain) IBOutlet NSTextField *progressLabel;
@property (retain) IBOutlet NSString *baseFilename;
+@property (nonatomic, retain) NSOperationQueue *queue;
+
- (IBAction)saveButtonPressed:(id)sender;
- (IBAction)openSelected:(id)sender;
@end
View
84 Tile_CutterAppDelegate.m
@@ -6,21 +6,26 @@
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
+#include <dispatch/dispatch.h>
#import "Tile_CutterAppDelegate.h"
#import "TileCutterView.h"
#import "NSImage-Tile.h"
#import "NSUserDefaults-MCColor.h"
+#import "TileOperation.h"
@interface Tile_CutterAppDelegate()
{
int tileHeight, tileWidth;
+ int tileRowCount, tileColCount;
+ int progressCol, progressRow;
}
+- (void)delayAlert:(NSString *)message;
@end
@implementation Tile_CutterAppDelegate
-@synthesize window, tileCutterView, widthTextField, heightTextField, rowBar, columnBar, progressWindow, progressLabel, baseFilename;
+@synthesize window, tileCutterView, widthTextField, heightTextField, rowBar, columnBar, progressWindow, progressLabel, baseFilename, queue;
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
{
@@ -47,9 +52,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[defaults setInteger:200 forKey:@"heightField"];
}
-
-
-
+ self.queue = [[[NSOperationQueue alloc] init] autorelease];
}
- (void)saveThread
{
@@ -66,33 +69,29 @@ - (void)saveThread
[columnBar setMaxValue:(double)[image columnsWithTileWidth:[widthTextField floatValue]]];
[columnBar setDoubleValue:0.];
- int rows = [image rowsWithTileHeight:tileHeight];
- int cols = [image columnsWithTileWidth:tileWidth];
- for (int row = 0; row < rows; row++)
+ progressCol = 0;
+ progressRow = 0;
+
+ tileRowCount = [image rowsWithTileHeight:tileHeight];
+ tileColCount = [image columnsWithTileWidth:tileWidth];
+
+ for (int row = 0; row < tileRowCount; row++)
{
- [rowBar setDoubleValue:(double)row];
- for (int col = 0; col < cols; col++)
+ for (int col = 0; col < tileColCount; col++)
{
-
- [columnBar setDoubleValue:(double)col];
- [progressLabel setStringValue:[NSString stringWithFormat:@"Processing row %d, column %d", row, col]];
- NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];
- NSImage *subImage = [image subImageWithTileWidth:(float)tileWidth tileHeight:(float)tileHeight column:col row:row];
- NSArray * representations = [subImage representations];
-
- NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations
- usingType:NSJPEGFileType properties:nil];
-
- NSString *outPath = [NSString stringWithFormat:@"%@_%d_%d.jpg", baseFilename, row, col];
- [bitmapData writeToFile:outPath atomically:YES];
-
-
- [innerPool drain];
+ TileOperation *op = [[TileOperation alloc] init];
+ op.column = col;
+ op.row = row;
+ op.tileWidth = tileWidth;
+ op.tileHeight = tileHeight;
+ op.image = image;
+ op.baseFilename = baseFilename;
+ op.delegate = self;
+ [queue addOperation:op];
+ [op release];
}
}
[image release];
-
- [NSApp endSheet:progressWindow];
[pool drain];
}
- (IBAction)saveButtonPressed:(id)sender
@@ -161,6 +160,39 @@ - (void)dealloc
[progressWindow release], progressWindow = nil;
[progressLabel release], progressLabel = nil;
[baseFilename release], baseFilename = nil;
+ [queue release], queue = nil;
[super dealloc];
}
+#pragma mark -
+- (void)operationDidFinishSuccessfully:(TileOperation *)op
+{
+ progressCol++;
+ if (progressCol >= tileColCount)
+ {
+ progressCol = 0;
+ progressRow++;
+ }
+ if (progressRow >= tileRowCount)
+ [NSApp endSheet:progressWindow];
+
+ [rowBar setDoubleValue:(double)progressRow];
+ [columnBar setDoubleValue:(double)progressCol];
+ [progressLabel setStringValue:[NSString stringWithFormat:@"Processing row %d, column %d", progressRow, progressCol]];
+
+
+}
+- (void)delayAlert:(NSString *)message
+{
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+ [alert addButtonWithTitle:@"Crud"];
+ [alert setMessageText:@"There was an error tiling this image."];
+ [alert setInformativeText:message];
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert beginSheetModalForWindow:[self window] modalDelegate:nil didEndSelector:nil contextInfo:nil];
+}
+- (void)operation:(TileOperation *)op didFailWithMessage:(NSString *)message
+{
+ [NSApp endSheet:progressWindow];
+ [self performSelector:@selector(delayAlert:) withObject:nil afterDelay:0.5];
+}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.