Previous Topic Tutorial Home Page Next Topic
Texture the Picture while Preserving Aspect Ratio


Extract the extent of the picture and scale the square into a rectangle with the same extent, to preserve the picture's aspect ratios upon texturing
Bbox2Bvr pictureBbox = picture.boundingBox();
Point2Bvr ll = pictureBbox.getMin();
Point2Bvr ur = pictureBbox.getMax();
NumberBvr xUpperRight = ur.getX();
NumberBvr yUpperRight = ur.getY();
Transform3Bvr scaleSquare = scale(xUpperRight, yUpperRight, toBvr(1));
NumberBvr maxHalfExtent = maxNumBvr(xUpperRight, yUpperRight);

GeoImage has the property that when it lies in the image plane it will have dimensions equal to its bitmap counterpart.
GeometryBvr geoImage = square.transform(scaleSquare).

The picture is normalized before texturing since the square's texture coordinates assume a unit square texture.
texture(picture.mapToUnitSquare());


© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

Previous Topic Tutorial Home Page Next Topic