3

I am struggling to find any good tutorials or posts about how to draw some text onto an NSImage. I have a feeling this is a pretty simple process but I just can't work it out!

I already have an NSImage and i need to end up with a manipulated NSImage at the end.

Has anybody got any clue how I can do this?

Thanks, Tom.

tarnfeld
  • 25,992
  • 41
  • 111
  • 146

1 Answers1

3

There could be an easier way, but personally I would go about it by using the following methods.

To put the text on your image, use the NSString method:

- (void)drawInRect:(NSRect)aRect withAttributes:(NSDictionary *)attributes

Then, (I'm assuming you want this retained in your image), use the NSImage method:

NSImage *newImage = [[NSImage alloc] initWithData:[myView dataWithPDFInsideRect:[oldImage frame];
justin
  • 5,811
  • 3
  • 29
  • 32