I have a Mac program that I am combining images and strings into an NSImage and then saving it as a .tif file to the desktop. It all works just fine but as I started to add attributes for my string like color, shadow and stroke I ran into a problem.
In the included image you can see the stroke is also being offset / effected by the offset for the shadow. It works fine with a shadow or a stroke but when I use both it looks strange? It appears the stroke appears to inherits the attributes of the shadow for offset and blur? I grey'd out code that is not a problem to make it easier to read.
OSX 10.7.5
xcode 4.5.2
Code.
Any Ideas?
In the included image you can see the stroke is also being offset / effected by the offset for the shadow. It works fine with a shadow or a stroke but when I use both it looks strange? It appears the stroke appears to inherits the attributes of the shadow for offset and blur? I grey'd out code that is not a problem to make it easier to read.
OSX 10.7.5
xcode 4.5.2
Code.
Code:
-(void)buildImage:(NSArray*)array{
[COLOR="Silver"]NSImage *toSave = [[NSImage alloc] initWithSize:CGSizeMake(1280, 720)];
NSImage *imageSource = [[NSImage alloc]initWithData:[array objectAtIndex:0]];
NSImage *rustPlate = [NSImage imageNamed:@"rusty-metal-plate.png"];
NSString *itemName = [array objectAtIndex:1];
NSString *itemWeight = [array objectAtIndex:3];
NSString *itemCost = [array objectAtIndex:4];
NSColor* tokenColor = [NSColor yellowColor];[/COLOR]
NSShadow* shadw = [[NSShadow alloc] init];
[shadw setShadowColor:[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.4]];
[shadw setShadowOffset:NSMakeSize( 5.0, -5.0 )];
[shadw setShadowBlurRadius:1.0];
NSDictionary *nameAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSFont fontWithName:@"Helvetica-Bold" size:82], NSFontAttributeName,tokenColor,NSForegroundColorAttributeName,[NSNumber numberWithFloat:-3.0],NSStrokeWidthAttributeName,shadw, NSShadowAttributeName, [NSColor blackColor],NSStrokeColorAttributeName, nil];
[COLOR="Silver"] NSDictionary *weightAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSFont fontWithName:@"Helvetica-Bold" size:36], NSFontAttributeName,tokenColor,NSForegroundColorAttributeName,[NSNumber numberWithFloat:-5.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil];
NSDictionary *costAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSFont fontWithName:@"MarkerFelt-Thin" size:140], NSFontAttributeName,tokenColor,NSForegroundColorAttributeName,[NSNumber numberWithFloat:-3.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil];[/COLOR]
[toSave lockFocus];
[rustPlate drawInRect:NSMakeRect(200,140,900,500) fromRect: NSZeroRect operation:NSCompositeCopy fraction:1.0];
[imageSource drawInRect:NSMakeRect(650,200,400,400) fromRect: NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[itemName drawInRect:NSMakeRect(260, 520, 450, 100) withAttributes: nameAttributes];
[itemWeight drawInRect:NSMakeRect(260, 420, 450, 100) withAttributes: weightAttributes];
[itemCost drawInRect:NSMakeRect(280, 180, 450, 250) withAttributes: costAttributes];
[toSave unlockFocus];
[COLOR="Silver"] NSData *data = [toSave TIFFRepresentation];
[data writeToFile: @"/Users/larspro/Documents/ERad files/saved/file.tif" atomically: NO];[/COLOR]
}
Any Ideas?