Image Crop

Range for Crop patch dimensions to fit Screen Dimensions?

usefuldesign.au's picture

Since the size of the image I'm displaying is a larger texture than what the billboard patch can render, I need to crop it to the section I wish to display.

Since I want to pan around the image with mouse, I need to update the crop dimensions as user drags. The crop patch is hard-wired to pixel co-ordinates of the mouse ATM.*

I want to put in a hard limit on how far (how much) the image will crop so that when the image is dragged to the edge of Window the cropping ceases to stop the image from shrinking the way it does in my composition.

In the given example shrinking starts when Crop X <0 or Crop X >360; or when Crop Y <> 0. But I can hard-code those numbers since a window resize or image zoom changes everything. (There is a Zoom control published to Root which you can change).

I'm having trouble discerning what the relationship of the Crop Inputs and the screen edges is.

*At moment it just follows the mouse since I haven't written the 'dragging' code to detect mouse-down and update co-ordinates when users drags but that's not relevant to this problem.

Image Rehab (Composition by smokris)

Author: smokris
License: MIT
Date: 2010.02.07
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

Core Image is incredibly powerful, but sometimes produces images with non-obvious properties. Image Rehab attempts to clean up some of these properties.

  • Image Origin is restored to (0,0) — potentially useful after cropping an image.
  • Unbounded Images are trimmed to the dimensions of the Rendering Destination.