[Top][All Lists]

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

Re: [RFC] Reading images

From: Alexander Malmberg
Subject: Re: [RFC] Reading images
Date: Sun, 21 Sep 2003 17:53:15 +0200

Pete French wrote:
> > No, and that's the important point. When you draw a 100x100 image into a
> > 100x100 rectangle, those coordinates are in user space (in points,
> > unless you changed it). If the device is not exactly 72 dpi, the
> > coordinates in device space will be different. Eg. on a 144 dpi device
> > (like a high resolution screen), the image will be 200x200 in device
> > space, and since GSReadRect: reads raw pixels from the device, you'd get
> > a 200x200 image back.
> *blink*
> now I am getting confused! If I make a view with a content rect that is
> 100x100, and then focus on it and init a bitmap from it, then is that
> bitmap going to be 100x100 ? Thats what I expect it to be.

100x100 points, yes. Not necessarily 100x100 (device) pixels, and
GSReadRect: is reading device pixels.

> > Well, you'd have to make sure that the window is 1024x1024 device
> > pixels, which may not correspond to 1024x1024 in the default user space.
> ...under what circumstances will this not be true ?

When the device is not 72 dpi.

> I'm thinking thatn theres a gap in my understanding of the default
> settings somewhere. I though that if I wrote some code to make a
> window 100 by 100 and ran it on any system (OSX, OpenStep, GNustep) then
> I would get 100 pixels square on the screen.

If you create a window that is 100 by 100, it will be 100 by 100
_points_. A point is the same as a pixel only if the device is 72 dpi.
If the device is not 72 dpi, the window will still be 100 by 100 points,
but not 100 by 100 pixels.

Most of the time, you don't need to worry about the exact relationship
between points and device pixels. Everything you do is in user space,
and the postscript interpreter/backend scales everything for you. It's
only when doing really low-level stuff, like reading the device's pixels
directly, that you need to be aware of the distinction between user
space and device space (points and pixels).

> This is (admittedly) derived
> from experience rather than ever actaully reading it documented as such
> anywhere though.

In practice, most systems pretend to be 72 dpi for performance and
simplicity, and because they can still get away with it (although
screens are approaching resolutions where you really need to scale
things properly; one of our strengths is that we already have a device
independent rendering model, so as long as people stick to the
interfaces, we can easily handle the switch to non-72 dpi screens).

- Alexander Malmberg

reply via email to

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