[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image flipping in NSCell and subclasses

From: Alexander Malmberg
Subject: Re: Image flipping in NSCell and subclasses
Date: Sun, 29 Sep 2002 01:44:01 +0200

Fred Kiefer wrote:
> I think I did understand what you did change with your patch on NSImage.
> What I never did understand is all the flipping of images, whereever
> they are drawn. And it still is not that clear to me, if we need that
> fixup. 

Yes, we need to do adjust the coordinates anytime that an image is drawn
in a flipped view. In a 'normal' (unflipped view), with the default
coordinate system, positive y goes up on the screen. In a flipped view,
positive y goes down. However, the coordinate system that the image is
composited _from_ is always the standard coordinate system, and it's in
the source coordinate system that the compositing rectangle is

(Remember, compositing is a pixel-to-pixel operation. It will never
scale, rotate, or flip the source image. The destination's coordinate
system is only used to find the destination point relative to which a
rectangle identical to the source rectangle is placed.)

If you want to draw an image with a 10 point border to the bottom edge,
you'd composite from (0,0) in the cached image window (the lower left
corner), to (0,10) in the view, the lower left corner in device space
(and also view space, since the coordinate systems are the same, except
for translations).

If you want to draw an image with a 10 point border to the top edge in a
flipped view, and you use (0,10) in the view's coordinate space (like
you can do with almost everything else, although things would be
visually flipped), then (0,10) will be converted to device space (ie. 10
points below the top edge), and the image will still extend up in device
space from that point, since the source coordinate system is still the
same. To get the expected results, you need to composite to
(0,10+height), ie. still the lower left corner _in_device_space_.

I hope this makes it clear. If not, I guess I'll have to draw pictures
to illustrate it or something :/. Anyway, it's worth noting that an
NSDrawBitmap() call would put the image inside the expected rectangle,
but since the coordinate system is flipped, the image would be drawn

- Alexander Malmberg

reply via email to

[Prev in Thread] Current Thread [Next in Thread]