[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
| 5 | * University of Illinois at Chicago |
---|
| 6 | * |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright |
---|
| 13 | * notice, this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above |
---|
| 15 | * copyright notice, this list of conditions and the following disclaimer |
---|
| 16 | * in the documentation and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the University of Illinois at Chicago nor |
---|
| 18 | * the names of its contributors may be used to endorse or promote |
---|
| 19 | * products derived from this software without specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | * |
---|
| 33 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
| 34 | * |
---|
| 35 | *****************************************************************************/ |
---|
| 36 | |
---|
| 37 | /* |
---|
| 38 | * Header for generic-image access routines: |
---|
| 39 | * getimginfo(), getimgdata() |
---|
| 40 | */ |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #define I_UNKNOWN 0 /* unknown type or inaccessible */ |
---|
| 44 | #define I_TIFF 1 /* TIFF raster image */ |
---|
| 45 | #define I_SGI 2 /* SGI raster image */ |
---|
| 46 | #define I_SUNRAS 3 /* Sun raster file */ |
---|
| 47 | #define I_SOFT 4 /* SoftImage raster image */ |
---|
| 48 | #define I_GIF 5 /* GIF image */ |
---|
| 49 | #define I_PNM 6 /* Portable bit/gray/pixmap */ |
---|
| 50 | #define I_RAW 7 /* raw image with imginfo header */ |
---|
| 51 | #define I_JPEG 8 /* JPEG image */ |
---|
| 52 | |
---|
| 53 | struct imginfo { |
---|
| 54 | int kind; /* Image type -- I_TIFF, I_SGI, ... */ |
---|
| 55 | int xsize, ysize; /* Image size */ |
---|
| 56 | int nsamp; /* Samples per pixel of image data */ |
---|
| 57 | int sampbits; /* Bits per sample */ |
---|
| 58 | int mapsize; /* Colormap entries (0 if absent) */ |
---|
| 59 | int mapsamp; /* Samples per colormap entry (0 if absent) */ |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | typedef struct img { |
---|
| 63 | #define IT_LONG 0 /* 32 bits per, ABGR, A is low-address byte */ |
---|
| 64 | #define IT_BIT 1 /* bit packed in bytes, MSB first */ |
---|
| 65 | #define IT_RGB 2 /* 24 bits per RGB, R is low-address byte */ |
---|
| 66 | #define IT_BYTE 3 /* 8 bits gray-scale */ |
---|
| 67 | int type; |
---|
| 68 | int xsize, ysize; /* image size in pixels */ |
---|
| 69 | int rowbytes; /* size of each image row, in bytes */ |
---|
| 70 | unsigned char *data; /* image data */ |
---|
| 71 | } IMG; |
---|
| 72 | |
---|
| 73 | /* |
---|
| 74 | * getimginfo returns image type, one of the I_* below. |
---|
| 75 | * It prints an error (only) if the file cannot even be opened. |
---|
| 76 | * |
---|
| 77 | * getimgdata diagnoses image type and also |
---|
| 78 | */ |
---|
| 79 | extern int getimginfo( char *fname, struct imginfo *info ); |
---|
| 80 | |
---|
| 81 | extern unsigned char *getimgdata( |
---|
| 82 | const char *fname, /* file name */ |
---|
| 83 | const struct imginfo *knowninfo, /* image info, if you have it */ |
---|
| 84 | struct imginfo *info, /* image info, filled in by getimgdata */ |
---|
| 85 | int yup, /* first row is... 0:bottom, 1:top */ |
---|
| 86 | int bpp, /* bytes per pixel, or 0:use image */ |
---|
| 87 | int byteorder /* 0: RGBA, 1: ABGR */ |
---|
| 88 | ); |
---|
| 89 | extern char *imgtypename[]; |
---|