1 // ------------------------------------------------------------------------------------------------ 2 // MODULE : CorrectLut 3 // LANGUAGE : C++ 4 // AUTHOR : Laurent Saboret 5 // DATE : Monday, February 21st 1994 6 // DESCRIPTION : Lookup table for a RGB pixel 7 // COMMENT : 8 // SCCSID : @(#)corr_lut.h 1.1 11:46:38 18 Dec 1996 9 // ---------------------------------------------------------------------------- 10 // Copyright (c) 1999 Digital Imaging Group, Inc. 11 // For conditions of distribution and use, see copyright notice 12 // in Flashpix.h 13 // ---------------------------------------------------------------------------- 14 // ------------------------------------------------------------------------------------------------ 15 #ifndef CorrectLut_h 16 #define CorrectLut_h 17 #ifndef Commun_h 18 #include "common.h" 19 #endif 20 // ------------------------------------------------------------------------------------------------ 21 22 // Includes 23 // -------- 24 25 #include "pixel.h" 26 #include "npixel.h" 27 28 // Constants 29 // --------- 30 typedef unsigned char Lut[256]; 31 32 // Classes declarations 33 // -------------------- 34 35 // not to include Fichier.h 36 class Fichier; 37 typedef Fichier* ptr_Fichier; 38 typedef Fichier& ref_Fichier; 39 40 struct CorrectLut; 41 typedef CorrectLut* ptr_CorrectLut; 42 typedef CorrectLut& ref_CorrectLut; 43 44 // Classes definitions 45 // ------------------- 46 47 // A CmykCorrectLut is a lookup table for a RGB pixel 48 struct CorrectLut { 49 50 public: 51 // Creates Identity LUT 52 CorrectLut(); 53 // Creates a classic LUT 54 CorrectLut(const Lut r, const Lut g, const Lut b); 55 // The 'rgb' LUT is applied on each channel, after the 3 other luts 56 CorrectLut(const Lut rgb, const Lut r, const Lut g, const Lut b); 57 58 // Copy 59 CorrectLut(const CorrectLut& toCopy); 60 CorrectLut& operator=(const CorrectLut& toCopy); 61 62 // Apply a color correction to a pixel 63 Pixel operator()(const Pixel& pixIn) const; 64 NPixel operator()(const NPixel& pixIn) const; 65 66 // Get the lookup table's description 67 Boolean IsActive() const; 68 void GetLuts(Lut r, Lut g, Lut b) const; 69 70 // Compute a*b 71 friend CorrectLut operator*(const CorrectLut& a, const CorrectLut& b); 72 73 virtual void Save(ref_Fichier file); 74 virtual void Load(ref_Fichier file, long version); 75 76 private: 77 Boolean active; // If false, *this is the Identity LUT 78 Lut red; 79 Lut green; 80 Lut blue; 81 }; 82 83 84 // Functions 'inline' 85 // ------------------ 86 IsActive()87 inline Boolean CorrectLut::IsActive() const 88 { 89 return active; 90 } 91 92 // Apply a color correction to a BIG ENDIAN pixel operator()93 inline Pixel CorrectLut::operator()(const Pixel& pixIn) const 94 { 95 if (active) 96 { 97 Pixel pixOut; 98 99 pixOut.alpha = pixIn.alpha; 100 pixOut.rouge = red[pixIn.rouge]; 101 pixOut.vert = green[pixIn.vert]; 102 pixOut.bleu = blue[pixIn.bleu]; 103 104 return pixOut; 105 } 106 else 107 { 108 return pixIn; 109 } 110 } 111 112 // Apply a color correction to a NATIVE pixel operator()113 inline NPixel CorrectLut::operator()(const NPixel& pixIn) const 114 { 115 if (active) 116 { 117 return NPixel(red[pixIn.Red()], green[pixIn.Green()], blue[pixIn.Blue()], pixIn.Alpha()); 118 } 119 else 120 { 121 return pixIn; 122 } 123 } 124 125 // Functions 'extern' 126 // ------------------ 127 128 // Variables 'extern' 129 // ------------------ 130 131 // ------------------------------------------------------------------------------------------------ 132 #endif // CorrectLut_h 133 // ------------------------------------------------------------------------------------------------ 134