From c18cefa94f79bb0c1ca8f3b0499f53b6396a2a9c Mon Sep 17 00:00:00 2001 From: matt handler Date: Fri, 22 Apr 2011 14:24:39 -0400 Subject: manipulate file and add square cropped to handler, silly way to do it ugh --- Classes/HJMOHandler.h | 2 ++ Classes/HJMOHandler.m | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'Classes') diff --git a/Classes/HJMOHandler.h b/Classes/HJMOHandler.h index 5e6715d..a103d78 100755 --- a/Classes/HJMOHandler.h +++ b/Classes/HJMOHandler.h @@ -24,6 +24,7 @@ enum HJMOState { stateNew, stateLoading, stateLoaded, stateReady, stateFailed } state; id oid; BOOL isDataReady; + BOOL squareCropped; NSURL* url; NSURLConnection* urlConn; NSMutableData* moData; @@ -36,6 +37,7 @@ } @property (readonly) enum HJMOState state; +@property BOOL squareCropped; @property (nonatomic, retain) id oid; @property (nonatomic, retain) NSURL* url; @property (nonatomic, retain) NSURLConnection* urlConn; diff --git a/Classes/HJMOHandler.m b/Classes/HJMOHandler.m index fb8643e..ab95766 100755 --- a/Classes/HJMOHandler.m +++ b/Classes/HJMOHandler.m @@ -11,11 +11,13 @@ #import "HJMOUser.h" #import "HJObjManager.h" #import "HJMOFileCache.h" +#import "HJManagedImageV.h" @implementation HJMOHandler @synthesize state; +@synthesize squareCropped; @synthesize oid; @synthesize url; @synthesize urlConn; @@ -341,6 +343,21 @@ [moLoadingDataFile closeFile]; self.moLoadingDataFile = nil; self.urlConn = nil; + + // manipulate file here + if ([users count] > 0) { + HJManagedImageV *user = [users objectAtIndex:0]; + if (self.squareCropped) { + NSLog(@"here"); + HJMOFileCache* fileCache = objManager.fileCache; + NSString* loadingFile = [[fileCache loadingFilePathForOid:oid] retain]; + UIImage *cropped = [[[UIImage imageWithContentsOfFile:loadingFile] imageByScalingAndCroppingForSize:CGSizeMake(100,100)] retain]; + //[[[UIImageView alloc] initWithImage:[moHandler.moData imageByScalingAndCroppingForSize:CGSizeMake(100,100)]] autorelease]; + [UIImagePNGRepresentation(cropped) writeToFile:loadingFile atomically:YES]; + NSLog(@"after"); + } + } + NSString* readyFilename = [self.objManager.fileCache loadingFinishedForOid:oid]; if (readyFilename==nil) { state = stateFailed; -- cgit v1.2.3