1 /*****************************************************************************/ 2 // Copyright 2007 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 /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_tone_curve.cpp#1 $ */ 10 /* $DateTime: 2012/05/30 13:28:51 $ */ 11 /* $Change: 832332 $ */ 12 /* $Author: tknoll $ */ 13 14 /*****************************************************************************/ 15 16 #include "dng_tone_curve.h" 17 18 #include "dng_assertions.h" 19 #include "dng_spline.h" 20 #include "dng_utils.h" 21 22 /******************************************************************************/ 23 dng_tone_curve()24dng_tone_curve::dng_tone_curve () 25 26 : fCoord () 27 28 { 29 30 SetNull (); 31 32 } 33 34 /******************************************************************************/ 35 operator ==(const dng_tone_curve & curve) const36bool dng_tone_curve::operator== (const dng_tone_curve &curve) const 37 { 38 39 return fCoord == curve.fCoord; 40 41 } 42 43 /******************************************************************************/ 44 SetNull()45void dng_tone_curve::SetNull () 46 { 47 48 fCoord.resize (2); 49 50 fCoord [0].h = 0.0; 51 fCoord [0].v = 0.0; 52 53 fCoord [1].h = 1.0; 54 fCoord [1].v = 1.0; 55 56 } 57 58 /******************************************************************************/ 59 IsNull() const60bool dng_tone_curve::IsNull () const 61 { 62 63 dng_tone_curve temp; 64 65 return (*this == temp); 66 67 } 68 69 /******************************************************************************/ 70 SetInvalid()71void dng_tone_curve::SetInvalid () 72 { 73 74 fCoord.clear (); 75 76 } 77 78 /******************************************************************************/ 79 IsValid() const80bool dng_tone_curve::IsValid () const 81 { 82 83 if (fCoord.size () < 2) 84 { 85 86 return false; 87 88 } 89 90 for (uint32 j = 0; j < fCoord.size (); j++) 91 { 92 93 if (fCoord [j] . h < 0.0 || fCoord [j] . h > 1.0 || 94 fCoord [j] . v < 0.0 || fCoord [j] . v > 1.0) 95 { 96 97 return false; 98 99 } 100 101 if (j > 0) 102 { 103 104 if (fCoord [j] . h <= fCoord [j - 1] . h) 105 { 106 107 return false; 108 109 } 110 111 } 112 113 } 114 115 return true; 116 117 } 118 119 /******************************************************************************/ 120 Solve(dng_spline_solver & solver) const121void dng_tone_curve::Solve (dng_spline_solver &solver) const 122 { 123 124 solver.Reset (); 125 126 for (uint32 index = 0; index < fCoord.size (); index++) 127 { 128 129 solver.Add (fCoord [index].h, 130 fCoord [index].v); 131 132 } 133 134 solver.Solve (); 135 136 } 137 138 /*****************************************************************************/ 139