Zoom image to pixel level

Posted by zaf on Stack Overflow See other posts from Stack Overflow or by zaf
Published on 2010-04-06T10:54:52Z Indexed on 2010/04/07 14:03 UTC
Read the original article Hit count: 292

For an art project, one of the things I'll be doing is zooming in on an image to a particular pixel. I've been rubbing my chin and would love some advice on how to proceed.

Here are the input parameters:

Screen:
sw - screen width
sh - screen height

Image:
iw - image width
ih - image height

Pixel:
px - x position of pixel in image
py - y position of pixel in image

Zoom:
zf - zoom factor (0.0 to 1.0)

Background colour:
bc - background colour to use when screen and image aspect ratios are different

Outputs:

The zoomed image (no anti-aliasing)
The screen position/dimensions of the pixel we are zooming to.

When zf is 0 the image must fit the screen with correct aspect ratio.
When zf is 1 the selected pixel fits the screen with correct aspect ratio.

One idea I had was to use something like povray and move the camera towards a big image texture or some library (e.g. pygame) to do the zooming. Anyone think of something more clever with simple pseudo code?

To keep it more simple you can make the image and screen have the same aspect ratio. I can live with that.

I'll update with more info as its required.

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about graphics