1 // ------------------------------------------------------------------------------------------------ 2 // 3 // TOOLKIT GLOBAL MANAGEMENT 4 // 5 // MODULE : SystemIVUE.h 6 // LANGUAGE : C++ 7 // AUTHOR : Philippe BOSSUT 8 // DATE : Wenesday 22 December 1993 9 // DESCRIPTION : 10 // COMMENT : This package is a part of the IVUE Toolkit I/O and the FlashPix Baseline I/O 11 // SCCSID : @(#)ri_sys.h 1.2 14:49:49 06 Jan 1997 12 // ---------------------------------------------------------------------------- 13 // Copyright (c) 1999 Digital Imaging Group, Inc. 14 // For conditions of distribution and use, see copyright notice 15 // in Flashpix.h 16 // ---------------------------------------------------------------------------- 17 // ------------------------------------------------------------------------------------------------ 18 #ifndef SystemToolkit_h 19 #define SystemToolkit_h 20 #ifndef Commun_h 21 #include "common.h" 22 #endif 23 24 // ------------------------------------------------------------------------------------------------ 25 26 // Includes 27 // -------- 28 29 #include <string.h> 30 31 #ifndef FicNom_h 32 #include "filename.h" 33 #endif 34 #ifndef FITypes_h 35 #include "b_types.h" 36 #endif 37 38 #ifndef IVUEToolkitIO_h 39 #include "ri_libio.h" 40 #endif 41 #include "fpxlib.h" 42 43 // Constants 44 // --------- 45 46 #define TOOLKIT_VERSION 1 // Version of the FlashPix Toolkits 47 #define TOOLKIT_NAME "Reference" // Version name of the FlashPix Toolkits 48 #define TOOLKIT_RELEASE 0 // Release of the FlashPix Toolkits 49 #define DEFAULT_TILE_SIZE (64*64*4) // Default size of the FlashPix tiles 50 #define MIN_TILE_SIZE (16*16*4) // Minimum size of a FlashPix tile 51 #define TOOLKIT_MIN_MEMORY 1000000 // Minimum memory size allowed to Toolkits 52 53 // Authorized color spaces in Baseline. See spec Table III.6 54 // We'll have one days something else than 32 bits pixel width. 55 56 typedef enum { 57 SPACE_32_BITS_RGB, // The 24 bits are stored in the LSB part of the long 58 SPACE_32_BITS_ARGB, 59 SPACE_32_BITS_RGBA, 60 SPACE_32_BITS_YCC, // The 24 bits are stored in the LSB part of the long 61 SPACE_32_BITS_AYCC, 62 SPACE_32_BITS_YCCA, 63 SPACE_32_BITS_M, // The 8 bits are stored in the LSB part of the long 64 SPACE_32_BITS_AM, // The 16 bits are stored in the LSB part of the long 65 SPACE_32_BITS_MA, // The 16 bits are stored in the LSB part of the long 66 SPACE_32_BITS_O, // The 8 bits are stored in the LSB part of the long 67 NON_AUTHORIZED_SPACE // We are in a forbidden case here 68 } FPXBaselineColorSpace; 69 70 // Class Declarations 71 // ------------------ 72 73 class PToolkitObject; 74 class PErrorsList; 75 class PSystemToolkit; 76 77 // To avoid include of PRIImage.h 78 class PRIImage; 79 80 // Class Definitions 81 // ----------------- 82 83 // General object: all the objects in the toolkits derive from it. 84 // It redefines new and delete to handle the memory. 85 class PToolkitObject { 86 public: 87 // redefinition of new and delete in order to used the toolkit memory management 88 void* operator new (size_t size); 89 void* operator new (size_t size, void *p); 90 void operator delete (void *p); 91 }; 92 93 // List of errors and messages 94 class PErrorsList : public PToolkitObject { 95 public: 96 PErrorsList(OSErr err, FicNom file); 97 ~PErrorsList(); 98 99 void AddErrorToList(OSErr err, FicNom file); 100 101 OSErr errorCode; 102 FicNom fileName; 103 PErrorsList* nextError; 104 105 static short nbErr; 106 }; 107 108 // SystemToolkit : Object managing global parameters and option settings. 109 // There is a single PSystemToolkit object declared as "global static" in PRIImage.cpp. 110 class PSystemToolkit : public PToolkitObject { 111 public: 112 PSystemToolkit (); 113 virtual ~PSystemToolkit (); 114 115 long SetTileSize (long newTileSize); 116 117 // The 3 following methods are for internal memory management only 118 void AvailableMemory (long* size); // Returns the memory available 119 void PurgeSystem (); // Purge all the memory reserved 120 // by SetAllowance 121 long PurgeSystemWithAmount (long memoryToBePurged); // Purge a requested amount of memory. 122 // Returns the memory really purged. 123 // (could be smaller than requested) 124 125 long SetWaitFunc (Typ_WaitFunc newWaitFunc); 126 long SetProgFunc (FPXProgressFunction newProgFunc); 127 128 long SetUnit (Typ_Unit newUnit); 129 long GetUnit (Typ_Unit* newUnit); 130 131 long GetToolkitVersion(); 132 long GetToolkitRelease(); 133 134 long SetInterleaving (Typ_Interleaving newInterleaving); 135 136 long SetAntialias (Typ_Antialias newAntialias); 137 long SetConvolution (Typ_Convolution newConvolution, Typ_Filter newFilter); 138 long SetConvolution (Typ_Convolution newConvolution); 139 140 long PreserveBackground (Boolean preserve); 141 long SetBackgroundColor (Pixel color, FPXBaselineColorSpace colorSpace = SPACE_32_BITS_RGB); 142 void SetUsedColorSpace (FPXBaselineColorSpace colorSpace); 143 144 long SetUserColorCode (Typ_ColorCode newUserColorCode); 145 long SetAlphaChannel (Boolean existAlphaChannel); 146 long SetFileColorCode (Typ_ColorCode newFileColorCode); 147 long SetColorConversion (Typ_ColorCode colorCode, 148 Typ_ModeltoRGB modeltoRGB, 149 Typ_RGBtoModel RGBtoModel); 150 151 long SetCompression (Typ_Compression newidCompressor, 152 Typ_Compressor newCompressor, 153 Typ_Decompressor newDecompressor); 154 long SetCompressionHandle (void* newCompressionHandle, long newHandleSize); 155 156 long SetActiveChannel(short newActiveChannel); 157 158 // The following methods are for internal use only 159 float Ratio(); 160 void SetToBackground(ptr_Pixel buffer, long width, long height); 161 162 void LockImage (PRIImage* image); 163 Boolean IsLockedImage (PRIImage* image); 164 void AddErrorToList(short message, OSErr err, FicNom file); 165 PErrorsList* GetErrorsList(); 166 void DeleteErrorsList(); 167 OSErr GetLastErrorFromList( FicNom file); 168 169 void SetManageOLE(Boolean theManageOLEOption); 170 Boolean GetManageOLE(); 171 172 long tileSize; // Size in bytes of the Image tiles 173 long tileWidth; // Width in Pixels of the Image tiles 174 175 Typ_WaitFunc fnctWaitFunc; // Pointer to Wait & Break function 176 FPXProgressFunction fnctProgFunc; // Pointer to Wait & Break function 177 178 Typ_Unit unit; // Unit used by the user in commands 179 float ratio; // Size of 1 Unit in mm 180 181 Typ_Interleaving interleaving; // Global interleaving mode 182 183 Typ_Antialias antialias; // Global antialiasing quality 184 Typ_Convolution convolution; // Global convolution quality 185 Typ_Filter filter; // Pointer to convolution function 186 187 Boolean preserveBackground; // Transparency on images edges 188 Pixel backgroundColor; // Color of the background 189 FPXBaselineColorSpace backgroundSpace; // Color Space used for the background color 190 191 Typ_ColorCode userColorCode; // User color model 192 Typ_ColorCode fileColorCode; // Output file color model 193 Boolean existAlpha; // Output file alpha channel flag 194 Typ_ModeltoRGB fnctModeltoRGB[8]; // Pointers to Model to RGB function 195 Typ_RGBtoModel fnctRGBtoModel[8]; // Pointers to RGB to Model function 196 197 Typ_Compression compression; // Global compression mode 198 Typ_Compressor fnctCompression; // Pointer to compression function 199 Typ_Decompressor fnctDecompression; // Pointer to decompression function 200 void* compressionHandle; // Pointer to compression option handle 201 long handleSize; // Size in bytes of the compression handle 202 203 short activeChannel; // Active Channel : 0.. x ; All = -1 204 205 short tableLog2[1024]; // Log2 table : used for fast subimage level computation 206 207 PRIImage* lockedImage; // Pointer to the current Image (avoid purge of this Image) 208 PErrorsList* errorsList; // Pointer to the current fatal errors list 209 210 Boolean manageOLE; // True if we are managing OLE 211 }; 212 213 // Global Functions Declaration : for internal use only 214 // ---------------------------- 215 216 extern void *FitsNew(size_t /* size */,void *p); 217 extern void *FitsNew(size_t size); 218 extern void FitsDelete(void *ptr); 219 extern bool GtheSystemToolkitInitialized(void); 220 221 // C functions used by the Toolkit (not exported): 222 // ----------------------------------------------- 223 float Toolkit_ConvertToMm (float x); 224 float Toolkit_ConvertToUnit (float x); 225 Boolean Toolkit_Interleave (Pixel* source, long width, long height); 226 Boolean Toolkit_UnInterleave (Pixel* source, Pixel* dest, long sourceWidth, long sourceHeight, 227 long destWidth, long destHeight); 228 Boolean Toolkit_CopyInterleaved (Pixel* image, long imageWidth, long imageHeight, 229 Pixel* rectangle, long rectWidth, long rectHeight, long i0, long j0); 230 short Toolkit_Log2 (long x); 231 Typ_Compression Toolkit_Compression(); 232 Typ_Convolution Toolkit_Convolution(); 233 short Toolkit_ActiveChannel(); 234 Boolean Toolkit_WriteOnBackground(); 235 Pixel Toolkit_BackgroundColor(); 236 Typ_ColorCode Toolkit_FileColorCode(); 237 Typ_ColorCode Toolkit_UserColorCode(); 238 Typ_ModeltoRGB Toolkit_ModeltoRGB(Typ_ColorCode code); 239 Typ_RGBtoModel Toolkit_RGBtoModel(Typ_ColorCode code); 240 long Toolkit_TileWidth(); 241 Boolean Toolkit_IsLockedIVUE (IVUE* ivue); 242 243 // C functions used by the FlashPix IO Toolkit (not exported): 244 // -------------------------------------------------------- 245 246 // 'inline' Functions 247 // ------------------ 248 249 // PSystemToolkit inline functions : 250 251 Ratio()252 inline float PSystemToolkit::Ratio () 253 254 { 255 return ratio; 256 } 257 GetToolkitVersion()258 inline long PSystemToolkit::GetToolkitVersion () 259 260 { 261 return(TOOLKIT_VERSION); 262 } 263 GetToolkitRelease()264 inline long PSystemToolkit::GetToolkitRelease () 265 266 { 267 return(TOOLKIT_RELEASE); 268 } 269 SetInterleaving(Typ_Interleaving newInterleaving)270 inline long PSystemToolkit::SetInterleaving(Typ_Interleaving newInterleaving) 271 272 { 273 interleaving = newInterleaving; return(0); 274 } 275 SetUserColorCode(Typ_ColorCode newUserColorCode)276 inline long PSystemToolkit::SetUserColorCode (Typ_ColorCode newUserColorCode) 277 278 { 279 userColorCode = newUserColorCode; return(0); 280 } 281 SetAlphaChannel(Boolean existAlphaChannel)282 inline long PSystemToolkit::SetAlphaChannel (Boolean existAlphaChannel) 283 284 { 285 existAlpha = existAlphaChannel; return(0); 286 } 287 SetFileColorCode(Typ_ColorCode newFileColorCode)288 inline long PSystemToolkit::SetFileColorCode (Typ_ColorCode newFileColorCode) 289 290 { 291 fileColorCode = newFileColorCode; return(0); 292 } 293 LockImage(PRIImage * image)294 inline void PSystemToolkit::LockImage (PRIImage* image) 295 296 { 297 lockedImage = image; 298 } 299 SetActiveChannel(short newActiveChannel)300 inline long PSystemToolkit::SetActiveChannel (short newActiveChannel) 301 302 { 303 activeChannel = newActiveChannel; return(0); 304 } 305 IsLockedImage(PRIImage * image)306 inline Boolean PSystemToolkit::IsLockedImage (PRIImage* image) 307 308 { 309 return (lockedImage == image); 310 } 311 GetErrorsList()312 inline PErrorsList* PSystemToolkit::GetErrorsList() 313 314 { 315 return errorsList; 316 } 317 318 // 'extern' Variables 319 // ------------------ 320 321 // Pointer to the PSystemToolkit object : THIS OBJECT MUST BE UNIQUE 322 323 extern PSystemToolkit* GtheSystemToolkit; 324 325 // This is declared only for compatibility with old LP code... 326 #define IVUE_System GtheSystemToolkit 327 328 // ------------------------------------------------------------------------------------------------ 329 #endif // SystemToolkit_h 330 // ------------------------------------------------------------------------------------------------ 331