cocoa - Setting color when drawing into a NSImage -
I am trying to tag a photo file with a date in Cocoa and it is in a small command line tool Trying to do It works fine ... but , I can not seem to be able to set the color. Am I doing something wrong?
#import & lt; Cocoa / Cocoa H & gt; Int main (int argc, const char * argv []) {[NSAPCimation share application]; NSAutoreleasePool * pool = [[NSAUTOriasius Alok] Init]; NSImage * image = [[NSImage alloc] initWithContentsOfFile: [NSString stringWithFormat: @ "% s", "/some/file.png"]]; If (image) {[image lockfocus]; Ensolar * Color = [Enkolar white color]; // These do not work ... [color set]; [Color Setstroke]; [Color setting]; NSString * string = [NSString stringWithFormat: @ "% @", [NSDT Date]]; [String drawpoint: nsmcpoint (10, 10) accompanying attributes: zero]; [Image Unlock Focus]; NSBitmapImageRep * bits = [NSBitmapImageRep imageRepWithData: [Image TIFF Representation]]; NSData * Data = [Bits representation type: NSPNG filetype property: zero]; [Write data file: @ "/ some / file page" atomic: no]; } [Pool drain]; Return 0; }
I believe that you set the color of text using the NSForegroundColorAttributeName attribute To do is drawAtPoint: withAttributes: Set, call instead of stroke / set.
Comments
Post a Comment