• 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: Brock Brandenberg <email@hidden>
  • Date: Mon, 09 Sep 2002 11:00:39 -0500

Hi John.

> When using cacheImg, this code does not work. I am pretty sure it just my
> misunderstanding of using NSImage drawing. My complicated NSView has scaled
> bounds and the origin is not at (0,0). The code appears to work when the
> NSView is not scaled and the origin is at (0,0) (i.e. when frame and bounds
> are the same). I thought I could figure out this scaling effect, but nothing I
> tried work. I quess the only question is:
>
> Is it possible to draw into an NSView using scaled and translated coordinates
> or must the view use unscaled coordinates with the origin at (0,0)? If it is
> possible, what needs to be different than when drawing directly to the NSView?
> Many parts of my applications use the actual coordinates and it would very
> inconvenient to rewrite them all to use (0,0) based pixels instead.

You can use scaled and translated coordinates to your heart's content. The
trick is in maintaining the proper transform, bounds and frame rects so that
you can always see what it is that you're drawing.

You can draw using "real size" coordinates and use the bounds-to-frame rect
ratio to bring them down to viewable size, or you can apply a transform to
your drawing focus to scale your coordinates down to normal size and keep
the frame and bounds rects at reasonable (like 1:1) proportions. Each view
or image maintains it's own transformation, so if you use a transform, you
need to make sure that you set it up for each view you're drawing into.

A key point in manipulating frame and bounds rects is that manipulating a
frame rect will alter the bounds rect, so when you call a method that does
this and you're manually maintaining a different bounds rect, you need to
follow right behind that method and move the bounds rect where you want it.
The converse is not true. That is, manipulating the bounds rect will not
affect the frame rect.

See if this helps point out the problem area.

Brock Brandenberg

----- industrial design @ www.bergdesign.com ------
_______________________________________________
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: Improving very slow NSView with cached NSImage
      • From: John Nairn <email@hidden>
References: 
 >Improving very slow NSView with cached NSImage (From: John Nairn <email@hidden>)

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