# Copyright (c) 1994 The Australian National University # Copyright (c) 1994-1997 Sun Microsystems, Inc. # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Author: Paul Mackerras (paulus@cs.anu.edu.au), # Department of Computer Science, # Australian National University. # RCS: @(#) $Id: photo.n,v 1.2 1998/09/14 18:22:59 stanton Exp $ # =head1 NAME Tk::Photo - Full-color images =for category Tk Image Classes =head1 SYNOPSIS S< >I<$widget>-EB(?I??, I?) =head1 DESCRIPTION A photo is an L whose pixels can display any color or be transparent. A photo image is stored internally in full color (32 bits per pixel), and is displayed using dithering if necessary. Image data for a photo image can be obtained from a file or a string, or it can be supplied from C code through a procedural interface. At present, only GIF, XBM, XPM, BMP, JPEG, PNG and PPM/PGM formats are supported, but an interface exists to allow additional image file formats to be added easily. A photo image is transparent in regions where no image data has been supplied or where it has been set transparent by the B subcommand. =head1 CREATING PHOTOS Photos are created using the B method. B supports the following I: =over 4 =item B<-data> =E I Specifies the contents of the image as a string. The string can contain base64 encoded data or binary data. The format of the string must be one of those for which there is an image file format handler that will accept string data. If both the B<-data> and B<-file> options are specified, the B<-file> option takes precedence. =item B<-format> =E I Specifies the name of the file format for the data specified with the B<-data> or B<-file> option. =item B<-file> =E I I gives the name of a file that is to be read to supply data for the photo image. The file format must be one of those for which there is an image file format handler that can read data. =item B<-gamma> =E I Specifies that the colors allocated for displaying this image in a window should be corrected for a non-linear display with the specified gamma exponent value. (The intensity produced by most CRT displays is a power function of the input value, to a good approximation; gamma is the exponent and is typically around 2). The value specified must be greater than zero. The default value is one (no correction). In general, values greater than one will make the image lighter, and values less than one will make it darker. =item B<-height> =E I Specifies the height of the image, in pixels. This option is useful primarily in situations where the user wishes to build up the contents of the image piece by piece. A value of zero (the default) allows the image to expand or shrink vertically to fit the data stored in it. =item B<-palette> =E I Specifies the resolution of the color cube to be allocated for displaying this image, and thus the number of colors used from the colormaps of the windows where it is displayed. The I string may be either a single decimal number, specifying the number of shades of gray to use, or three decimal numbers separated by slashes (/), specifying the number of shades of red, green and blue to use, respectively. If the first form (a single number) is used, the image will be displayed in monochrome (i.e., grayscale). =item B<-width> =E I Specifies the width of the image, in pixels. This option is useful primarily in situations where the user wishes to build up the contents of the image piece by piece. A value of zero (the default) allows the image to expand or shrink horizontally to fit the data stored in it. =back =head1 IMAGE METHODS When a photo image is created, Tk also creates a new object. This object supports the B and B methods described in L which can be used to enquire and modify the options described above. Those options that write data to the image generally expand the size of the image, if necessary, to accommodate the data written to the image, unless the user has specified non-zero values for the B<-width> and/or B<-height> configuration options, in which case the width and/or height, respectively, of the image will not be changed. The following addition methods are available for photo images: =over 4 =item I<$image>-EB Blank the image; that is, set the entire image to have no data, so it will be displayed as transparent, and the background of whatever window it is displayed in will show through. =item I<$image>-EB(I ?,I