If an image is scanned, saved, restored, and displayed using identity
projections throughout, it is displayed at real size, that is, at the same
size as the original image on paper. It is also displayed with the top
left corner of the original image aligned with the top left corner of the
image field, and truncated if necessary at the bottom and right edges.
This may not be what you require. You may want to scale the original
image up or down to just fill the display screen (or, more generally, the
image field) in either the horizontal or vertical dimension as
appropriate, while maintaining the correct aspect ratio.
Note: On graphics terminals other than the 3193, GDDM's User Control
facility allows end users of application programs to pan and zoom
image fields.
This programming example shows you how to change the scale of an image:
IMPROG4: PROC OPTIONS(MAIN);
DCL MIN BUILTIN;
DCL APPL_ID FIXED BIN(31); /* Application image identifier */
DCL PROJ_ID FIXED BIN(31); /* Projection identifier */
DCL H_PIXELS FIXED BIN(31); /* Application image horizontal */
/* size in pixels */
DCL V_PIXELS FIXED BIN(31); /* Application image vertical */
/* size in pixels */
DCL DH_PIXELS FIXED BIN(31); /* Display image horizontal */
/* size in pixels */
DCL DV_PIXELS FIXED BIN(31); /* Display image vertical */
/* size in pixels */
DCL IM_TYPE FIXED BIN(31); /* Image type */
DCL RES FIXED BIN(31); /* Defined/undefined resolutn. */
DCL RES_UNIT FIXED BIN(31) /* Resolution */
INIT(0); /* Units to be inches */
DCL H_RES FLOAT DEC(6); /* Application image horizontal */
/* resolution (pixels per inch) */
DCL V_RES FLOAT DEC(6); /* Application image vertical */
/* resolution (pixels per inch) */
DCL DH_RES FLOAT DEC(6); /* Display image horizontal */
/* resolution (pixels per inch) */
DCL DV_RES FLOAT DEC(6); /* Display image vertical */
/* resolution (pixels per inch) */
DCL H_SIZE FLOAT DEC(6); /* Application image hor. size */
DCL V_SIZE FLOAT DEC(6); /* Application image ver. size */
DCL DH_SIZE FLOAT DEC(6); /* Display image horiz. size */
DCL DV_SIZE FLOAT DEC(6); /* Display image vert. size */
DCL H_RATIO FLOAT DEC(6); /* Horizontal and vertical */
DCL V_RATIO FLOAT DEC(6); /* size ratios of display */
/* image to appln. image */
DCL SCALE FLOAT DEC(6); /* Scale factor */
DCL (ATTYPE,ATTVAL,COUNT) /* ASREAD parameters */
FIXED BIN(31);
DCL DESCR CHAR(30); /* IMARST parameter */
CALL FSINIT;
CALL IMAGID(APPL_ID);
CALL IMARST(APPL_ID,0,'IMAGNAME',30,DESCR);/*Restore saved */ A
/* image to application image */
/* Query the application image */
CALL IMAQRY(APPL_ID,H_PIXELS,V_PIXELS,IM_TYPE, B
RES,RES_UNIT,H_RES,V_RES);
/* Query the display image */
CALL IMAQRY(0,DH_PIXELS,DV_PIXELS,IM_TYPE, C
RES,RES_UNIT,DH_RES,DV_RES);
H_SIZE=H_PIXELS/H_RES; /* Application image size inches*/
V_SIZE=V_PIXELS/V_RES; /* (horizontal and vertical) */
DH_SIZE=DH_PIXELS/DH_RES; /*Display image size in inches */
DV_SIZE=DV_PIXELS/DV_RES; /*(horizontal and vertical) */
H_RATIO=DH_SIZE/H_SIZE; /* Size ratios of display */
V_RATIO=DV_SIZE/V_SIZE; /* image to application image */
SCALE=MIN(H_RATIO,V_RATIO); /* Required scale factor */ D
CALL IMPGID(PROJ_ID); /* Get a projection identifier */
CALL IMPCRT(PROJ_ID); /* Create a new projection */
CALL IMRSCL(PROJ_ID,SCALE,SCALE);/* Scale the image to suit */
CALL IMRPLR(PROJ_ID,0,0.0,0.0,0);/*End of projection definition*/
CALL IMXFER(APPL_ID,0,PROJ_ID); /* Transfer to display screen */ E
CALL ASREAD(ATTYPE,ATTVAL,COUNT);
CALL FSTERM;
%INCLUDE ADMUPINA;
%INCLUDE ADMUPINF;
%INCLUDE ADMUPINI;
END IMPROG4;
Figure 97. Program that scales an image to fit the display screen
In the above program, at A , a previously saved image IMAGENAME is
restored using the identity projection.
At B , the application image attributes are queried, to obtain sizes in
pixels, and resolutions.
At C , attributes of the image field on the current GDDM page are
similarly queried. By default, this image field occupies the entire
display screen.
At D , the lesser of the horizontal and vertical size ratios (of display
image to application image) is assigned to SCALE, that is subsequently
used as the horizontal and vertical scale factor in a projection
definition. This calculation works only for images with defined
resolution.
At E , this projection is applied to the restored image as it is
transferred to the display screen.
|