• 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
Help w/ NSPICTImageRep, NSQuickdrawView & offscreen drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help w/ NSPICTImageRep, NSQuickdrawView & offscreen drawing


  • Subject: Help w/ NSPICTImageRep, NSQuickdrawView & offscreen drawing
  • From: Esteban <email@hidden>
  • Date: Sat, 18 May 2002 13:33:21 -0700

Hi,

This is a somewhat two part e-mail and long, but I would appreciate your time to read through this and provide help. Thank you in advance.

What I need to do is get the NSImage equivalent of the PicHandle I created from a CIconHandle, and display that in a NSImageView.

Part 1:

I was able to obtain a PicHandle to a Picture record from the CIconHandle of the CICN. Basically I ended up creating a new Picture and drawing to it directly with PlotCIconHandle.

I created pictImageRep using imageRepWithData without a problem. The NSImage image was created without a problem too with the imagerep's size. However, when I set my image inside the imageView, it displays a blank image.

here's a codesnippet of what i did.

CIconHandle cicnHandle = GetCIcon(cicnID);
PicHandle cicnPicture;
Rect qdCICNRect = &( (**cicnHandle).iconPMap.bounds);

MacSetRect(&pictParams.srcRect, qdCICNRect.left, qdCICNRect.top, qdCICNRect.right, qdCICNRect.bottom);
//pictParams.hRes = eHRes72dpi;
//pictParams.vRes = eVRes72dpi;
pictParams.hRes = (**cicnHandle).iconPMap.hRes;
pictParams.vRes = (**cicnHandle).iconPMap.vRes;

pictParams.version = -2;
pictParams.reserved1 = 0;
pictParams.reserved2 = 0;

cicnPicture = OpenCPicture(&pictParams);

PlotCIconHandle(&qdCICNRect, kAlignNone, kTransformNone, cicnHandle);

ClosePicture();

pictImageRep = [NSPICTImageRep imageRepWithData:[NSData dataWithBytes:(void *)*cicnPicture length:GetHandleSize(cicnPicture)]];
image = [[NSImage alloc] initWithSize:[pictImageRep size]];

[image lockFocus];
[pictImageRep drawAtPoint:NSMakePoint(0,0)];

[image unlockFocus];

KillPicture(cicnPicture);
[imageView setImage:image];


I've looked at the Mac OS X Dev and Cocoa dev archives, to see if i could find a solution. Even Apple's Cocoa bMoviePalette uses similar code to mine, except they get the PicHandle from the Quicktime function GetMoviePosterPict([self QTMovie]), I don't see why me creating my own PicHandle with OpenCPicture should be any different.

I noticed that the docs state that the PICT format stream is (usually) obtained directly from a PICT file or document. However, I would like to be able to convert my PicHandle to an NSPICTImageRep without having to write a file.

Might I perhaps need to use the Carbon Collection Manager to flatten down the Picture struct that PicHandle handles? Or maybe add 512 bytes to the header of the Picture record the PicHandle points to? If so how do i do this?

I've searched cocoa.mamasam.com and googled NSPICTImageRep info on and off Apple's developer site, but haven't found much info on getting around this problem.


Part 2:
Failing at part one i tried to use NSQuickDrawView to do some offscreen drawing of CICN icons using PlotCIcon (Carbon call). My attempt is to use the NSQuickDrawView as a stepping stone to draw the CICNs and then get the dataWithPDFInsideRect to then initialize an NSImage with imageWithData.

I've created a subclass of NSQuickDrawView without attaching it to any NSWindow, and overwrote - (void) drawRect:(NSRect)rect

This works fine except that since I have no window attached to the view, it draws the images somewhere up the menubar on-screen. My thought was that since it had no window it would automatically draw things offscreen. I think I solved this by HidePen and ShowPen and nesting the PlotCIcon in between.

I tried another solution by creating a NSWindow containing the custom NSQuickDrawView. Then I assumed I could hide the NSWindow and thus cleverly have offscreen drawing in the NSQuickDrawView. Except this also fails to draw offscreen, although the images do end up being drawn on-screen. (Unless I use HidePen and ShowPen)

However, if the NSWindow shows, then the drawing occurs inside the NSQuickDrawView, although it doesnt update.

Can anyone provide insights and advice on setting up NSQuickDrawView correctly so that I may draw to it offscreen and later get its image data with dataWithPDFInsideRect, to create an NSImage?


Any help/suggestions/insights is appreciated (especially on part 1)

Thank you,

-Esteban
email@hidden
_______________________________________________
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.

  • Prev by Date: Buttons in an NSTableView
  • Next by Date: Re: Buttons in an NSTableView
  • Previous by thread: Re: Buttons in an NSTableView
  • Next by thread: Going around "display:"
  • Index(es):
    • Date
    • Thread