• 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
initWithFocusedViewRect problem - corrected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

initWithFocusedViewRect problem - corrected


  • Subject: initWithFocusedViewRect problem - corrected
  • From: Andrei Kolev <email@hidden>
  • Date: Mon, 23 Jul 2001 20:26:19 +0300

Please ignore the previous message - the initWithFocusedViewRect: is not on the line it should be!

Hello everybody!

In one of my methods which returns NSBitmapImageRep I have:

//...some unimportant stuff goes here, assume x, y, , tempWindow, backgroundColor, backgroundRect are defined, theImage is passed to the method as an argument

[[tempWindow contentView] lockFocus];

[backgroundColor set];
[NSBezierPath fillRect:backgroundRect];

[theImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];

//...some not very complex NSBezierPath operations here

newBitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:backgroundRect];

[[tempWindow contentView] unlockFocus];

return([newBitmapImageRep autorelease]);

After calling the method (assuming the returned NSBitmapImageRep is newBitmapImageRep, somePath, fileProperties and filePermissions are defined) I have :

noErr=[[NSFileManager defaultManager] createFileAtPath:somePath contents:
[newBitmapImageRep
representationUsingType:NSJPEGFileType
properties:fileProperties]
attributes:filePermissions];

In general, this works fine. But in some rare cases the saved image (the returned NSBitmapImageRep) is corrupted. It seems that the NSBitmapImageRep is initialized before the drawing is finished - I have 1/3, 1/2, 3/4 (some portion) of the image and/or the background drawn and the rest is the window background (the JPEG file is valid, the image stored in it is partially drawn). I think I have to synchronize the off-screen drawing and the initWithFocusedViewRect method. How to do that?

Thank you in advance for any suggestions and ideas you could share.

Best Regards,
Andrei


  • Prev by Date: Newbie Cocoa Question - Drawing Text
  • Next by Date: Re: Goofy NSDrawer behavior
  • Previous by thread: Newbie Cocoa Question - Drawing Text
  • Next by thread: C question about structs
  • Index(es):
    • Date
    • Thread