1 /*****************************************************************************/ 2 // Copyright 2007-2019 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 #include "dng_tone_curve.h" 10 11 #include "dng_assertions.h" 12 #include "dng_spline.h" 13 #include "dng_utils.h" 14 15 /******************************************************************************/ 16 dng_tone_curve()17dng_tone_curve::dng_tone_curve () 18 19 : fCoord () 20 21 { 22 23 SetNull (); 24 25 } 26 27 /******************************************************************************/ 28 operator ==(const dng_tone_curve & curve) const29bool dng_tone_curve::operator== (const dng_tone_curve &curve) const 30 { 31 32 return fCoord == curve.fCoord; 33 34 } 35 36 /******************************************************************************/ 37 SetNull()38void dng_tone_curve::SetNull () 39 { 40 41 fCoord.resize (2); 42 43 fCoord [0].h = 0.0; 44 fCoord [0].v = 0.0; 45 46 fCoord [1].h = 1.0; 47 fCoord [1].v = 1.0; 48 49 } 50 51 /******************************************************************************/ 52 IsNull() const53bool dng_tone_curve::IsNull () const 54 { 55 56 dng_tone_curve temp; 57 58 return (*this == temp); 59 60 } 61 62 /******************************************************************************/ 63 SetInvalid()64void dng_tone_curve::SetInvalid () 65 { 66 67 fCoord.clear (); 68 69 } 70 71 /******************************************************************************/ 72 IsValid() const73bool dng_tone_curve::IsValid () const 74 { 75 76 if (fCoord.size () < 2) 77 { 78 79 return false; 80 81 } 82 83 for (uint32 j = 0; j < fCoord.size (); j++) 84 { 85 86 if (fCoord [j] . h < 0.0 || fCoord [j] . h > 1.0 || 87 fCoord [j] . v < 0.0 || fCoord [j] . v > 1.0) 88 { 89 90 return false; 91 92 } 93 94 if (j > 0) 95 { 96 97 if (fCoord [j] . h <= fCoord [j - 1] . h) 98 { 99 100 return false; 101 102 } 103 104 } 105 106 } 107 108 return true; 109 110 } 111 112 /******************************************************************************/ 113 Solve(dng_spline_solver & solver) const114void dng_tone_curve::Solve (dng_spline_solver &solver) const 115 { 116 117 solver.Reset (); 118 119 for (uint32 index = 0; index < fCoord.size (); index++) 120 { 121 122 solver.Add (fCoord [index].h, 123 fCoord [index].v); 124 125 } 126 127 solver.Solve (); 128 129 } 130 131 /*****************************************************************************/ 132