up | Inhaltsverzeichniss | Kommentar

Manual page for PhotoCD(3)

PhotoCD - Reader for Kodak(tm) PhotoCD(tm) format

DESCRIPTION

Kodak PhotoCD allows digital data generated by scanning 35-mm film to be encoded and stored on a compact disc. The XIL library supports the following PhotoCD image resolutions:

	BASE/16		 192 x  128 pixels
	BASE/4		 384 x  256
	BASE			 768 x  512
	4BASE		1536 x 1024
	16BASE		3072 x 2048
	64BASE		6144 x 4096

Images on Kodak PhotoCD are stored in the XIL library's "photoycc" color space. The PhotoCD reader returns images in this color space. To display or further process the images, you normally convert the images to an RGB color space, such as "rgb709," by calling xil_color_convert.3 or xil_color_correct.3 Grayscale or "Black and White" versions of the images may be obtained by converting to "y709" or "ylinear."

Using the PhotoCD Reader

To access images from PhotoCD files, supply "SUNWPhotoCD" for the devicename argument in xil_create_from_device.3 and specify NULL for the deviceObj argument. After creating the device image, it may be used as a source to any XIL image operation. Because PhotoCD is a read-only device, the device image created by this device handler is read-only (see xil_is_readable.3 and xil_is_writable.3 Trying to use the device image as a destination will generate an error.

Use xil_get_device_attribute.3 and xil_set_device_attribute.3 to get and set the PhotoCD reader attributes, as described below. The PhotoCD reader also recognizes XilDevice objects so you can initialize attributes when the device image is createed. See xil_device_create.3 for more details on XilDevice objects.

PhotoCD Reader Attributes

The following paragraphs describe the attributes of the XIL PhotoCD reader. Note that some attributes are "set/get" and others are "get-only." This is noted under the Access heading for each attribute.

FILEPATH

Description
Pathname to a PhotoCD image pack. Setting this attribute directs the library to use the image pack with the given pathname when the device image is used as a source to an operation. This attribute does not need to be reset for each use of the image as a source, only when a different image is desired. There is no default pathname; trying to use the created device image before setting this attribute will cause an error to be generated.
Access
set/get
Type
char *

RESOLUTION

Description
Describes the size of the image to be obtained from the PhotoCD. The default value is XIL_PHOTOCD_BASE, or 768 x 512 pixels. After the value has been set, the FILEPATH attribute may be changed without changing the desired resolution. Conversely, the resolution may be changed without resetting the path attribute to get different size of the same image from the same image pack.

Access
set/get
Type
typedef enum{
	XIL_PHOTOCD_16TH_BASE,
	XIL_PHOTOCD_4TH_BASE,
	XIL_PHOTOCD_BASE,
	XIL_PHOTOCD_4X_BASE,
	XIL_PHOTOCD_16X_BASE
	XIL_PHOTOCD_64X_BASE
} XilPhotoCDResolution;

MAX_RESOLUTION

Description
Describes the maximum size obtainable from this image pack. Not all image sizes are available within an image pack (This is sometimes done for pre-recorded PhotoCDs). This attribute returns the maximum size which may be asked for using the RESOLUTION attribute. The value returned is one of the sizes described by XilPhotoCDResolution.

Access
get-only
Type
XilPhotoCDResolution

ROTATION

Description
Describes the amount of rotation required to display the image in its proper orientation. The value returned is one of the enumeration constants shown below.

Access
get-only
Type
typedef enum{
	XIL_PHOTOCD_CCW0,
	XIL_PHOTOCD_CCW90,
	XIL_PHOTOCD_CCW180,
	XIL_PHOTOCD_CCW270
} XilPhotoCDRotate;

ERRORS

For a complete list of XIL error messages by number, consult Appendix B of the XIL Programmer's Guide.

EXAMPLES

The following example opens a PhotoCD image, checking the image's ROTATION attribute so it can rotate the image, if necessary, before displaying it, and so the display window has the appropriate dimensions. The example also converts the image to the RGB 709 color space for display.

XilSystemState   state;
XilImage         ycc_photocd_image;
XilImage         rgb_photocd_image;
XilImage         rotated_photocd_image;
XilImage         display;
XilPhotoCDRotate rotation;
unsigned int     width;
unsigned int     height;
unsigned int     nbands;
unsigned int     datatype;
char*            pathname = "my_photocd_image";

/*
 *  Open the XIL Library
 */
state = xil_open();

if (state == NULL) {
    fprintf(stderr, "Failed to open XIL library.0);
    return 1;
}

/*
 *  Create the PhotoCD device image.
 */
ycc_photocd_image =
    xil_create_from_device(state, "SUNWPhotoCD", NULL);

if (ycc_photocd_image == NULL) {
    fprintf(stderr, "Failed to construct SUNWPhotoCD device image.0);
    return 1;
}

/*
 *  Set the file name.  The default resolution is XIL_PHOTOCD_BASE.
 */
xil_set_device_attribute(ycc_photocd_image, "FILEPATH", pathname);

/*
 *  Get the rotation attribute and image's width and height.
 */
xil_get_device_attribute(ycc_photocd_image,
                         "ROTATION", (void**)&rotation);

xil_get_info(ycc_photocd_image, &width, &height, &nbands, &datatype);

/*
 *  Transpose (rotate) the image based on the rotation angle.  
 *  Depending upon the rotation angle, construct an image to store 
 *  the transpose results.
 */
switch (rotation) {
  case XIL_PHOTOCD_CCW0:
    rotated_photocd_image = ycc_photocd_image;
    break;

  case XIL_PHOTOCD_CCW90:
    /*
     *  Flip the image's width and the height.
     */
    rotated_photocd_image =
        xil_create(state, height, width, nbands, datatype);
    xil_transpose(ycc_photocd_image,
                  rotated_photocd_image, XIL_FLIP_90);
    xil_get_info(rotated_photocd_image, &width, &height, NULL, NULL);
    break;

  case XIL_PHOTOCD_CCW180:
    rotated_photocd_image =
        xil_create(state, width, height, nbands, datatype);
    xil_transpose(ycc_photocd_image,
                  rotated_photocd_image, XIL_FLIP_180);
    break;

  case XIL_PHOTOCD_CCW270:
    /*
     *  Flip the image's width and the height.
     */
    rotated_photocd_image =
        xil_create(state, height, width, nbands, datatype);
    xil_transpose(ycc_photocd_image,
                  rotated_photocd_image, XIL_FLIP_270);
    xil_get_info(rotated_photocd_image, &width, &height, NULL, NULL);
    break;
}

/*
 *  Perform a color space conversion to rgb709.
 */
rgb_photocd_image =
    xil_create(state, width, height, nbands, datatype);

/*
 *  Set color spaces to for color space conversion
 */
xil_set_colorspace(rotated_photocd_image,
    xil_colorspace_get_by_name(state, "photoycc"));
xil_set_colorspace(rgb_photocd_image,
    xil_colorspace_get_by_name(state, "rgb709"));

/*
 *  Convert the image's color space so it can be displayed
 */
xil_color_convert(rotated_photocd_image, rgb_photocd_image);

/*
 *  ...code to open an X window of correct depth...
 */
display = xil_create_from_window(state, xdisplay, xwindow);

if (display == NULL) {
    fprintf(stderr, "Failed to construct display device0);
    return 1;
}
 
/*
 *  Copy the RGB image to the display and continue to
 *  redisplay on Expose events.
 */
xil_copy(rgb_photocd_image, display);

while (1) {
    XNextEvent(xdisplay, &event);
    if (event.xany.type == Expose) {
        xil_copy(rgb_photocd_image, display);
    } else if (event.xany.type == ButtonPress)
        break;
    }
}

/*
 *  Destroy images.
 */
xil_destroy(display);
xil_destroy(rgb_photocd_image);

if(rotated_photocd_image != ycc_photocd_image) {
    xil_destroy(rotated_photocd_image);
}

xil_destroy(ycc_photocd_image);

NOTES

The xil_set_device_attribute.3 and xil_get_device_attribute.3 calls are used to modify the default behavior of specific device images. Generic attributes of images are set by individual function calls.

SEE ALSO

xil_color_convert.3 xil_create_from_device.3 xil_open.3


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 07/October/97