#include <bmpalint.h>
Public Types | |
enum | PaletteSortType { SORT_NONE, SORT_USE, SORT_LUMINANCE, SORT_HUE } |
Public Member Functions | |
BitmapExportPaletteInterface () | |
INT32 | GetNumberOfColours () |
void | SetPaletteSortType (PaletteSortType newSortType) |
PaletteSortType | GetPaletteSortType () |
BYTE | GetRed (INT32 index) |
BYTE | GetGreen (INT32 index) |
BYTE | GetBlue (INT32 index) |
INT32 | GetFlags (INT32 index) |
void | SetRed (INT32 index, BYTE red) |
void | SetGreen (INT32 index, BYTE green) |
void | SetBlue (INT32 index, BYTE blue) |
void | SetFlags (INT32 index, INT32 flags) |
INT32 | SortedValueToRealValue (INT32 index) |
INT32 | RealValueToSortedValue (INT32 index) |
Static Public Member Functions | |
static void | InvalidateSortedPalette () |
Private Types | |
enum | { MAX_PALETTE_ENTRYS = 256 } |
Private Member Functions | |
CC_DECLARE_MEMDUMP (BitmapExportPaletteInterface) | |
void | ValidateSortedPalette () |
Static Private Member Functions | |
static INT32 | LuminanceComparisonFn (const INT32 *arg1, const INT32 *arg2) |
static INT32 | HueComparisonFn (const INT32 *arg1, const INT32 *arg2) |
Private Attributes | |
INT32 | m_PaletteRealToSorted [MAX_PALETTE_ENTRYS] |
INT32 | m_PaletteSortedToReal [MAX_PALETTE_ENTRYS] |
PaletteSortType | m_CurrentSortType |
Static Private Attributes | |
static bool | m_SortedPaletteValid |
Definition at line 111 of file bmpalint.h.
|
Definition at line 117 of file bmpalint.h. 00117 { 00118 MAX_PALETTE_ENTRYS = 256 00119 };
|
|
Definition at line 122 of file bmpalint.h. 00122 {SORT_NONE, SORT_USE, SORT_LUMINANCE, SORT_HUE};
|
|
Definition at line 117 of file bmpalint.cpp. 00118 { 00119 // Make sure the sorted palette is generated before it is used 00120 InvalidateSortedPalette(); 00121 00122 m_CurrentSortType = SORT_USE; // Default sort type 00123 }
|
|
|
|
Definition at line 198 of file bmpalint.cpp. 00199 { 00200 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00201 00202 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00203 00204 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00205 ERROR3IF(!palette, "There is no palette - This should never happen"); 00206 return palette->Data[m_PaletteSortedToReal[index]].Blue; 00207 }
|
|
Definition at line 209 of file bmpalint.cpp. 00210 { 00211 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00212 00213 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00214 00215 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00216 ERROR3IF(!palette, "There is no palette - This should never happen"); 00217 return palette->Data[m_PaletteSortedToReal[index]].Flags; 00218 }
|
|
Definition at line 187 of file bmpalint.cpp. 00188 { 00189 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00190 00191 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00192 00193 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00194 ERROR3IF(!palette, "There is no palette - This should never happen"); 00195 return palette->Data[m_PaletteSortedToReal[index]].Green; 00196 }
|
|
Definition at line 164 of file bmpalint.cpp. 00165 { 00166 if (BmapPrevDlg::m_pExportOptions->GetSupportsPalette()) 00167 { 00168 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00169 ERROR3IF(!palette, "There is no palette - This should never happen"); 00170 return palette->NumberOfColours; 00171 } 00172 else 00173 return 0; 00174 }
|
|
Definition at line 322 of file bmpalint.cpp. 00323 { 00324 return m_CurrentSortType; 00325 }
|
|
Definition at line 176 of file bmpalint.cpp. 00177 { 00178 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00179 00180 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00181 00182 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00183 ERROR3IF(!palette, "There is no palette - This should never happen"); 00184 return palette->Data[m_PaletteSortedToReal[index]].Red; 00185 }
|
|
Definition at line 403 of file bmpalint.cpp. 00404 { 00405 INT32 paletteIndex1 = *arg1; 00406 INT32 paletteIndex2 = *arg2; 00407 00408 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00409 ERROR3IF(!palette, "There is no palette - This should never happen"); 00410 00411 // Extract the red, green, and blue values for the first index 00412 INT32 red1 = palette->Data[paletteIndex1].Red; 00413 INT32 green1 = palette->Data[paletteIndex1].Green; 00414 INT32 blue1 = palette->Data[paletteIndex1].Blue; 00415 00416 // Extract the red, green, and blue values for the first index 00417 INT32 red2 = palette->Data[paletteIndex2].Red; 00418 INT32 green2 = palette->Data[paletteIndex2].Green; 00419 INT32 blue2 = palette->Data[paletteIndex2].Blue; 00420 00421 // Get the Hue value corresponding to the first RGB triplet. 00422 DocColour colour1(red1, green1, blue1); 00423 INT32 hue1, saturation1, value1; 00424 colour1.GetHSVValue(&hue1, &saturation1, &value1); 00425 00426 // Get the Hue value corresponding to the first RGB triplet. 00427 DocColour colour2(red2, green2, blue2); 00428 INT32 hue2, saturation2, value2; 00429 colour2.GetHSVValue(&hue2, &saturation2, &value2); 00430 00431 if (hue1 > hue2) 00432 return 1; 00433 else if (hue1 < hue2) 00434 return -1; 00435 00436 ERROR3IF(hue1 != hue2, "This is not possible!"); 00437 00438 // If the Hue values are the same, then put in order of Saturation 00439 if (saturation1 < saturation2) 00440 return 1; 00441 else if (saturation1 > saturation2) 00442 return -1; 00443 00444 ERROR3IF(saturation1 != saturation2, "This is not possible!"); 00445 00446 // If the saturation values are the same, then the final step is 00447 // to put them in order of Value 00448 if (value1 < value2) 00449 return 1; 00450 else if (value1 > value2) 00451 return -1; 00452 00453 ERROR3IF(value1 != value2, "This is not possible!"); 00454 00455 00456 return 0; // Everything is eqaul 00457 }
|
|
Definition at line 159 of file bmpalint.cpp. 00160 { 00161 m_SortedPaletteValid = false; 00162 }
|
|
Definition at line 337 of file bmpalint.cpp. 00338 { 00339 INT32 paletteIndex1 = *arg1; 00340 INT32 paletteIndex2 = *arg2; 00341 00342 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00343 ERROR3IF(!palette, "There is no palette - This should never happen"); 00344 00345 // Extract the red, green, and blue values for the first index 00346 INT32 red1 = palette->Data[paletteIndex1].Red; 00347 INT32 green1 = palette->Data[paletteIndex1].Green; 00348 INT32 blue1 = palette->Data[paletteIndex1].Blue; 00349 00350 // Extract the red, green, and blue values for the first index 00351 INT32 red2 = palette->Data[paletteIndex2].Red; 00352 INT32 green2 = palette->Data[paletteIndex2].Green; 00353 INT32 blue2 = palette->Data[paletteIndex2].Blue; 00354 00355 // Get the Luminance value corresponding to the first RGB triplet. 00356 double luminance1 = ( 0.299 * red1 ) + ( 0.587 * green1 ) + ( 0.114 * blue1 ); 00357 00358 // Get the Luminance value corresponding to the second RGB triplet. 00359 double luminance2 = ( 0.299 * red2 ) + ( 0.587 * green2 ) + ( 0.114 * blue1 ); 00360 00361 // This will sort in descending Hue values. 00362 if (luminance1 < luminance2) 00363 return 1; 00364 else if (luminance1 > luminance2) 00365 return -1; 00366 00367 ERROR3IF(luminance1 != luminance2, "This is not possible!"); 00368 00369 if (red1 < red2 ) 00370 return 1; 00371 else if (red1 > red2) 00372 return -1; 00373 00374 ERROR3IF(red1 != red2, "This is not possible!"); 00375 00376 if (green1 < green2 ) 00377 return 1; 00378 else if (green1 > green2) 00379 return -1; 00380 00381 ERROR3IF(green1 != green2, "This is not possible!"); 00382 00383 if (blue1 < blue2 ) 00384 return 1; 00385 else if (blue1 > blue2) 00386 return -1; 00387 00388 ERROR3IF(blue1 != blue2, "This is not possible!"); 00389 00390 return 0; // The red, green and blue are equal 00391 }
|
|
Definition at line 150 of file bmpalint.cpp. 00151 { 00152 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00153 if (index == BitmapExportPaletteControl::INVALID_COLOUR_VALUE) 00154 return BitmapExportPaletteControl::INVALID_COLOUR_VALUE; 00155 else 00156 return m_PaletteSortedToReal[index]; 00157 }
|
|
Definition at line 244 of file bmpalint.cpp. 00245 { 00246 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00247 00248 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00249 00250 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00251 ERROR3IF(!palette, "There is no palette - This should never happen"); 00252 palette->Data[m_PaletteSortedToReal[index]].Blue = blue; 00253 palette->Data[m_PaletteSortedToReal[index]].Flags &= LOCKED_COLOUR; 00254 }
|
|
Definition at line 256 of file bmpalint.cpp. 00257 { 00258 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00259 00260 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00261 00262 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00263 ERROR3IF(!palette, "There is no palette - This should never happen"); 00264 palette->Data[m_PaletteSortedToReal[index]].Flags = flags; 00265 }
|
|
Definition at line 232 of file bmpalint.cpp. 00233 { 00234 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00235 00236 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00237 00238 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00239 ERROR3IF(!palette, "There is no palette - This should never happen"); 00240 palette->Data[m_PaletteSortedToReal[index]].Green = green; 00241 palette->Data[m_PaletteSortedToReal[index]].Flags &= LOCKED_COLOUR; 00242 }
|
|
Definition at line 316 of file bmpalint.cpp. 00317 { 00318 m_CurrentSortType = newSortType; 00319 InvalidateSortedPalette(); // make sure palette is regenerated on next use 00320 }
|
|
Definition at line 220 of file bmpalint.cpp. 00221 { 00222 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00223 00224 ERROR3IF(index == -1, "Function called with an invalid palette index"); 00225 00226 ExtendedPalette *palette = BmapPrevDlg::m_pExportOptions->GetExtendedPalette(); 00227 ERROR3IF(!palette, "There is no palette - This should never happen"); 00228 palette->Data[m_PaletteSortedToReal[index]].Red = red; 00229 palette->Data[m_PaletteSortedToReal[index]].Flags &= LOCKED_COLOUR; 00230 }
|
|
Definition at line 133 of file bmpalint.cpp. 00134 { 00135 if (!m_SortedPaletteValid) ValidateSortedPalette(); 00136 if (index == BitmapExportPaletteControl::INVALID_COLOUR_VALUE) 00137 return BitmapExportPaletteControl::INVALID_COLOUR_VALUE; 00138 else 00139 return m_PaletteSortedToReal[index]; 00140 }
|
|
Definition at line 267 of file bmpalint.cpp. 00268 { 00269 // Initalize the palette to not sorted - This is done what ever the sort type 00270 // so all the colours are in the palette. A possible optimisation would be to 00271 // only do this step on first use and when the number of colours in the palette 00272 // changes 00273 INT32 i; 00274 00275 for (i = 0; i < GetNumberOfColours(); ++i) 00276 m_PaletteSortedToReal[i] = i; 00277 00278 switch (m_CurrentSortType) 00279 { 00280 case SORT_USE: 00281 case SORT_NONE: 00282 { 00283 // The default palette order (as it comes from Gavin/SimonK code) is by 00284 // use so there is nothing to do in this case (the for loops above and 00285 // below this switch sort out the palette indexes). 00286 break; 00287 } 00288 case SORT_HUE: 00289 { 00290 qsort(m_PaletteSortedToReal, GetNumberOfColours(), sizeof(INT32), 00291 (INT32 (*)(const void*,const void*))HueComparisonFn); 00292 break; 00293 } 00294 00295 case SORT_LUMINANCE: 00296 { 00297 qsort(m_PaletteSortedToReal, GetNumberOfColours(), sizeof(INT32), 00298 (INT32 (*)(const void*,const void*))LuminanceComparisonFn); 00299 break; 00300 } 00301 default: 00302 { 00303 // Don't use ERROR3's here as they upset the rendering code 00304 TRACE( _T("Unknown sort type used\n")); 00305 break; 00306 } 00307 } 00308 00309 // Copy the changes into the other array 00310 for (i = 0; i < GetNumberOfColours(); ++i) 00311 m_PaletteRealToSorted[m_PaletteSortedToReal[i]] = i; 00312 00313 m_SortedPaletteValid = true; 00314 }
|
|
Definition at line 131 of file bmpalint.h. |
|
Definition at line 126 of file bmpalint.h. |
|
Definition at line 129 of file bmpalint.h. |
|
Definition at line 135 of file bmpalint.h. |