• 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
Re: Improving very slow NSView with cached NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improving very slow NSView with cached NSImage


  • Subject: Re: Improving very slow NSView with cached NSImage
  • From: Greg Titus <email@hidden>
  • Date: Mon, 9 Sep 2002 12:36:04 -0700

On Monday, September 9, 2002, at 11:35 AM, John Nairn wrote:
I might be very close. I changed the view used to draw the image to
have same same bounds as my NSView (which also has scaled and
translated bounds). I then found I had to shift the rect in drawRect to
get it positioned correctly. Now the graphics appears to be of the
right size and in the right position, but the NSImage is very (very)
blurry while normal drawing with NSImage is clear. I don't see how
further transformations will help because that will just break the
things that are now correct.

The good news is that resizing and scrolling a very fast even with
large calculations. Now if only it wasn't so blurry?

The blurriness is because of the scaling.

When you are creating your cacheImg, you create it with the size of your bounds, but this is the scaled size. If you zoomed to 200% for instance, then the size of your bounds is only half the width and height as the number of pixels you are really drawing. So your cache image will only have half the pixels. When you then make the cacheImg -drawInRect:fromRect:operation:fraction: call, Quartz 2D is forced to stretch the image to twice its natural size in order to display it in the destination rectangle - thus the blurriness.

Basically, you want to make an image that is the size of your view in pixels, not the size of your view in scaled coordinates.

So you need to make an NSAffineTransform that is scaled appropriately, and call size = [scaleTransform transformSize:[self bounds].size], in order to get the right size. Then when you draw into the cache, lockFocus, and then [scaleTransform concat], to apply the scaling to the drawing in the image.

Hope this helps,
-- Greg
_______________________________________________
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.

References: 
 >Re: Improving very slow NSView with cached NSImage (From: John Nairn <email@hidden>)

  • Prev by Date: Re: localizedStringForKey:value:table: changed in 10.2?
  • Next by Date: Sample code with CGFunctionRef?
  • Previous by thread: Re: Improving very slow NSView with cached NSImage
  • Next by thread: NSDrawer newbie question
  • Index(es):
    • Date
    • Thread