|
|
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."
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.
FILEPATH
RESOLUTION
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
ROTATION
XIL_PHOTOCD_CCW0, XIL_PHOTOCD_CCW90, XIL_PHOTOCD_CCW180, XIL_PHOTOCD_CCW270 } XilPhotoCDRotate;
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);
|
|
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 07/October/97