00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Alexander 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: IMG_FileParm.h ( IMG Library, C++) 00015 * 00016 * COMMENTS: 00017 * Parameter class for options to IMG_File::open() and IMG_File::create() 00018 */ 00019 #ifndef __IMG_FILE_PARMS_H__ 00020 #define __IMG_FILE_PARMS_H__ 00021 00022 #include "IMG_API.h" 00023 00024 #include <SYS/SYS_Types.h> 00025 #include <UT/UT_FilterType.h> 00026 #include <UT/UT_StringArray.h> 00027 #include <UT/UT_IntArray.h> 00028 #include <UT/UT_Rect.h> 00029 #include <PXL/PXL_LumFuncs.h> 00030 00031 #include "IMG_FileTypes.h" 00032 00033 #if 0 00034 class IMG_TileFileInfo; 00035 #else 00036 class IMG_TileOptions; 00037 #endif 00038 00039 00040 /// @brief File options for manipulating image data on load or save. 00041 /// This class allows you to modify the incoming or outgoing image data by 00042 /// scaling, flipping, converting or cropping the data. It can be optionally 00043 /// passed to IMG_File::open() or IMG_File::create() 00044 class IMG_API IMG_FileParms 00045 { 00046 public: 00047 IMG_FileParms(); 00048 00049 /// This method turns off any option that would result in image 00050 /// translation. 00051 void readAsIs(); 00052 00053 // DATA ORGANIZATION ---------------------------------------------------- 00054 00055 /// @brief Convert to a different data type 00056 /// convert the image to this data type, if needed (default = use native) 00057 void setDataType(IMG_DataType dt); 00058 00059 /// @brief Convert to a different number of pixel components 00060 /// convert to a standard color model, if needed (RGB, RGBA, single). 00061 /// When moving from fewer components to more components, the 00062 /// data is either duplicated (1chan->RGB) or generated (RGB-RGBA, A=1). 00063 void setColorModel(IMG_ColorModel cm); 00064 00065 /// @brief Interleaves or deinterleaves pixel data 00066 /// Determines how to format the data. 00067 /// - IMG_INTERLEAVE_AS_IS - leave it interleaved or non, as in the file. 00068 /// - IMG_INTERLEAVED - always interleave (rgbrgbrgb). Default. 00069 /// - IMG_NON_INTERLEAVED - always non-interleaved (rrrgggbbb) 00070 void setInterleaved(IMG_Interleave i); 00071 00072 /// If the color model is set to IMG_1CHAN, and the actual color model 00073 /// is RGB or higher, this method determines how to convert the vector 00074 /// into a scalar. By default, the luminance is taken. 00075 void setLuminanceFunc(PXL_LumFunction f); 00076 00077 /// If true, alpha will be read into its own plane, instead of an RGBA 00078 /// color plane. Color will be read as its own plane as well, RGB. 00079 void readAlphaAsPlane(); 00080 00081 /// If demoting from a deep raster to an RGB(A) image, these methods 00082 /// allow you to specify the plane(s) to copy to RGB(A), by name or index. 00083 /// Selects a plane by index. Indices are specified from 1 to # planes. 00084 void selectPlanes(const UT_IntArray &planeindices); 00085 00086 /// If demoting from a deep raster to an RGB(A) image, these methods 00087 /// allow you to specify the plane(s) to copy to RGB(A), by name or index. 00088 /// Selects several planes by numeric pattern, ie. "1", "1 3 4", "[1-3] 5" 00089 void selectPlanes(const char *pattern); 00090 00091 /// If demoting from a deep raster to an RGB(A) image, these methods 00092 /// allow you to specify the plane(s) to copy to RGB(A), by name or index. 00093 /// Selects serveral planes by name pattern, such as "C", "C A Pz" "P? C*" 00094 void selectPlaneNames(const char *name); 00095 00096 00097 /// RESOLUTION ----------------------------------------------------------- 00098 /// using these methods always scales. To crop, use the data window methods 00099 00100 /// Scale the image to resolutuion (x,y). (0 = use orginal dimension) 00101 void scaleImageTo(int x, int y, UT_FilterType ft=UT_FILTER_BOX); 00102 00103 /// scale the image by scaling factors (x,y). 00104 void scaleImageBy(fpreal x, fpreal y, UT_FilterType ft=UT_FILTER_BOX); 00105 00106 /// limit the image to a maximum resolution. Scale to this res, preserving 00107 /// the aspect ratio. 00108 void limitImageRes(int x, int y, UT_FilterType ft=UT_FILTER_BOX); 00109 00110 /// images must be read as powers of two. Does not preserve aspect ratio. 00111 void powerTwoOnly(); 00112 00113 // DATA WINDOW --------------------------------------------------------- 00114 00115 /// Normally, a data window is expanded or cropped to the image resolution. 00116 /// calling this will always read only the data window. 00117 /// Used only for reading. 00118 void setDataWindowOnly(); 00119 00120 /// read the image region in 'area' only (even if we need to crop or expand 00121 /// the image to fill it). Used only for reading. 00122 void setWindow(const UT_DimRect &area); 00123 00124 /// read the image region in 'area' in UV coords. Used only for reading. 00125 void setWindow(float u1, float v1, float u2, float v2); 00126 00127 // ORIENTATION ---------------------------------------------------------- 00128 00129 /// options for orienting and flipping the image. Default orienation is 00130 /// LEFT_FIRST, BOTTOM_FIRST. You can set each to 'none' if you don't care. 00131 void orientImage(IMG_XOrientation x, IMG_YOrientation y); 00132 00133 /// @brief Flip the image in either direction. 00134 /// flip the images in either direction. May cancel out any orientation 00135 /// flipping. 00136 /// @{ 00137 void flipImageVertical(); 00138 void flipImageHorizontal(); 00139 /// @} 00140 00141 /// rotate the image 90', flopping it on its side. 00142 void flopImage(); 00143 00144 00145 // COLOR CORRECTION ----------------------------------------------------- 00146 00147 /// @brief Color correct an image using a LUT 00148 /// apply a lookup table to the data, but only those planes that match the 00149 /// scope (ie, "C spec diff", "C*", "*beauty*") 00150 void applyLUT(const char *lut, const char *plane_scope = "*"); 00151 00152 /// @brief Color correct an image using a gamma setting 00153 /// Apply gamma to the planes matching the scope (ie, "C spec diff", "C*", 00154 /// "*beauty*") 00155 void applyGamma(fpreal gamma, const char *gamma_scope = "*"); 00156 00157 // FORMAT SPECIFIC OPTIONS ---------------------------------------------- 00158 00159 /// set an input/output tag option for the format. 00160 void setOption(const char *option, const char *value); 00161 00162 /// options are a list of argument pairs, such as "artist", "Tom Smith". 00163 /// The options list is terminated by a NULL. 00164 void setOptions(const char **options); 00165 00166 /// options are in a whitespace separated string "Artist 'Tom Jones'" 00167 void setOptionsString(const char *option_pair_string); 00168 00169 /// options are specified in the IMG_TileOptions structure 00170 void setOptions(const IMG_TileOptions &info_with_options); 00171 00172 /// @brief Enable the tile inteface for reading or writing 00173 /// If called, we're reading or writing tiles using IMG_File::readTile 00174 /// and IMG_File::writeTile. The scanline versions will not work. 00175 void useTileInterface(); 00176 00177 /// If set, files will not report errors and subsequent scanlines 00178 /// will be returned as black. 00179 void continueOnError(); 00180 00181 private: 00182 IMG_DataType myDataType; 00183 IMG_ColorModel myColorModel; 00184 IMG_XOrientation myOrientX; 00185 IMG_YOrientation myOrientY; 00186 int myResX, myResY; 00187 fpreal myScaleX, myScaleY; 00188 UT_FilterType myFilterType; 00189 fpreal myGamma; 00190 IMG_Interleave myInterleaved; 00191 PXL_LumFunction myLumFunc; 00192 00193 unsigned myFlipHorizontal : 1, 00194 myFlipVertical : 1, 00195 myFlopImage : 1, 00196 myReadDataWindowOnly :1, 00197 myReadAreaFlag :1, 00198 myReadUVAreaFlag : 1, 00199 myUseTiles :1, 00200 myUseLUT : 1, 00201 myPowerTwoRes :1, 00202 myResLimit:1, 00203 myAlphaSplit : 1, 00204 myContinueOnError : 1; 00205 00206 UT_DimRect myReadArea; 00207 fpreal myReadUVArea[4]; 00208 UT_String myLUTFilename; 00209 UT_String myLUTScope; 00210 UT_String myGammaScope; 00211 UT_String mySelectPlaneName; 00212 UT_IntArray mySelectPlaneIndex; 00213 00214 UT_StringArray myOptions; 00215 UT_StringArray myOptionValues; 00216 00217 friend class IMG_File; 00218 }; 00219 00220 00221 00222 #endif
1.5.9