• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drawing a view inside an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing a view inside an image


  • Subject: Drawing a view inside an image
  • From: Simone Manganelli <email@hidden>
  • Date: Mon, 9 Dec 2002 13:12:23 -0800

How would one go about drawing the image of an NSView into an NSImage? Specifically, I want to draw what a specific NSProgressIndicator looks like into a specific NSImage, which I then want to use in my program. How would one go about doing that? I've tried it using this code:

NSProgressIndicator *theProgressIndicator;
NSImage *theProgBarImage = [[NSImage alloc] initWithSize:NSMakeSize(60,12)];
NSRect theRect = NSMakeRect(0,0,60,12);
[theProgBarImage lockFocus];
theProgressIndicator = [[NSProgressIndicator alloc] init];
[theProgressIndicator setFrame:theRect];
[theProgressIndicator setMaxValue:50];
[theProgressIndicator setDoubleValue:25];
[theProgressIndicator stopAnimation:nil];
[theProgressIndicator drawRect:theRect];
[theProgBarImage unlockFocus];
[theProgressIndicator release];

However, it doesn't seem to work. What am I doing wrong? This is my first time using progress indicators and images in a programmatic way, as opposed to laying out the progress indicators in Interface Builder and simply manipulating their contents, so I'm not exactly sure how to go about doing things.

-- Simone Manganelli
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Drawing a view inside an image
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: Subject: Re: Cocoa Book / ok, ok.
  • Next by Date: Sample MultiColumn Text Code Posted - With BUG!
  • Previous by thread: Re: orderOut a sheet while app is hidden
  • Next by thread: Re: Drawing a view inside an image
  • Index(es):
    • Date
    • Thread