24 #include <QDomDocument>
25 #include <QDomElement>
58 myTransparentSingleValuePixel.
min = theValue;
59 myTransparentSingleValuePixel.
max = theValue;
74 myTransparentThreeValuePixel.
red = theRedValue;
75 myTransparentThreeValuePixel.
green = theGreenValue;
76 myTransparentThreeValuePixel.
blue = theBlueValue;
107 if ( theValue != theValue )
113 bool myTransparentPixelFound =
false;
118 if (( theValue >= myTransparentPixel.
min && theValue <= myTransparentPixel.
max ) ||
122 myTransparentPixelFound =
true;
128 if ( myTransparentPixelFound )
130 return (
int )(( float )theGlobalTransparency *( 1.0 - ( myTransparentPixel.
percentTransparent / 100.0 ) ) );
133 return theGlobalTransparency;
147 if ( theRedValue != theRedValue || theGreenValue != theGreenValue || theBlueValue != theBlueValue )
153 bool myTransparentPixelFound =
false;
158 if ( myTransparentPixel.
red == theRedValue )
160 if ( myTransparentPixel.
green == theGreenValue )
162 if ( myTransparentPixel.
blue == theBlueValue )
164 myTransparentPixelFound =
true;
172 if ( myTransparentPixelFound )
174 return (
int )(( float )theGlobalTransparency *( 1.0 - ( myTransparentPixel.
percentTransparent / 100.0 ) ) );
177 return theGlobalTransparency;
187 QDomElement rasterTransparencyElem = doc.createElement(
"rasterTransparency" );
190 QDomElement singleValuePixelListElement = doc.createElement(
"singleValuePixelList" );
194 QDomElement pixelListElement = doc.createElement(
"pixelListEntry" );
197 pixelListElement.setAttribute(
"percentTransparent", QString::number( it->percentTransparent ) );
198 singleValuePixelListElement.appendChild( pixelListElement );
200 rasterTransparencyElem.appendChild( singleValuePixelListElement );
205 QDomElement threeValuePixelListElement = doc.createElement(
"threeValuePixelList" );
209 QDomElement pixelListElement = doc.createElement(
"pixelListEntry" );
213 pixelListElement.setAttribute(
"percentTransparent", QString::number( it->percentTransparent ) );
214 threeValuePixelListElement.appendChild( pixelListElement );
216 rasterTransparencyElem.appendChild( threeValuePixelListElement );
218 parentElem.appendChild( rasterTransparencyElem );
230 QDomElement currentEntryElem;
232 QDomElement singlePixelListElem = elem.firstChildElement(
"singleValuePixelList" );
233 if ( !singlePixelListElem.isNull() )
235 QDomNodeList entryList = singlePixelListElem.elementsByTagName(
"pixelListEntry" );
237 for (
int i = 0; i < entryList.size(); ++i )
239 currentEntryElem = entryList.at( i ).toElement();
240 sp.
percentTransparent = currentEntryElem.attribute(
"percentTransparent" ).toDouble();
242 if ( currentEntryElem.hasAttribute(
"pixelValue" ) )
244 sp.
min = sp.
max = currentEntryElem.attribute(
"pixelValue" ).toDouble();
248 sp.
min = currentEntryElem.attribute(
"min" ).toDouble();
249 sp.
max = currentEntryElem.attribute(
"max" ).toDouble();
254 QDomElement threeValuePixelListElem = elem.firstChildElement(
"threeValuePixelList" );
255 if ( !threeValuePixelListElem.isNull() )
257 QDomNodeList entryList = threeValuePixelListElem.elementsByTagName(
"pixelListEntry" );
259 for (
int i = 0; i < entryList.size(); ++i )
261 currentEntryElem = entryList.at( i ).toElement();
262 tp.
red = currentEntryElem.attribute(
"red" ).toDouble();
263 tp.
green = currentEntryElem.attribute(
"green" ).toDouble();
264 tp.
blue = currentEntryElem.attribute(
"blue" ).toDouble();
265 tp.
percentTransparent = currentEntryElem.attribute(
"percentTransparent" ).toDouble();