[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 894
Date       : Wed Apr 26 14:46:29 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/oilbitmap.cpp
   M /Trunk/XaraLX/wxOil/outptpng.cpp
   M /Trunk/XaraLX/wxOil/pngutil.cpp

Swap BGR <=> RGB when writing out palette data under wxGTK. Ugly!


Diff:
Index: Trunk/XaraLX/wxOil/outptpng.cpp
===================================================================
--- Trunk/XaraLX/wxOil/outptpng.cpp	(revision 893)
+++ Trunk/XaraLX/wxOil/outptpng.cpp	(revision 894)
@@ -604,9 +604,15 @@
 				// Palette supplied in RGBQUAD form 
 				for (INT32 i = 0; i < PaletteEntries; i++)
 				{
+#if defined(__WXGTK__)
+					pPNGPalette->red 	= pQuadPalette->rgbBlue;	// NOTE! Swap BGR <=> BGR
+					pPNGPalette->green 	= pQuadPalette->rgbGreen;
+					pPNGPalette->blue 	= pQuadPalette->rgbRed;		// NOTE! Swap BGR <=> BGR
+#else
 					pPNGPalette->red 	= pQuadPalette->rgbRed;
 					pPNGPalette->green 	= pQuadPalette->rgbGreen;
 					pPNGPalette->blue 	= pQuadPalette->rgbBlue;
+#endif
 					// skip to the next palette entry
 					pQuadPalette++;
 					pPNGPalette++;
@@ -617,9 +623,15 @@
 				// Palette supplied in LOGPALETTE form 
 				for (INT32 i = 0; i < PaletteEntries; i++)
 				{
+#if defined(__WXGTK__)
+					pPNGPalette->red  	= pPalette->palPalEntry[i].peBlue;	// NOTE! Swap BGR <=> BGR
+					pPNGPalette->green 	= pPalette->palPalEntry[i].peGreen;
+					pPNGPalette->blue 	= pPalette->palPalEntry[i].peRed;	// NOTE! Swap BGR <=> BGR
+#else
 					pPNGPalette->red  	= pPalette->palPalEntry[i].peRed;
 					pPNGPalette->green 	= pPalette->palPalEntry[i].peGreen;
 					pPNGPalette->blue 	= pPalette->palPalEntry[i].peBlue;
+#endif
 					pPNGPalette++;
 				}
 			}
@@ -724,7 +736,9 @@
 		//png_set_packing(png_ptr);
 
 		// flip bgr pixels to rgb
+#if !defined(__WXGTK__)
 		png_set_bgr(png_ptr);
+#endif
 
 		// swap bytes of 16 bit files to most significant bit first
 		png_set_swap(png_ptr);
Index: Trunk/XaraLX/wxOil/oilbitmap.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 893)
+++ Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 894)
@@ -2646,9 +2646,16 @@
 	if (ok) ok = pFilter->Write(Entries);
 	for (UINT32 i = 0; i < NumberOfPaletteEntries; i++)
 	{
+#if defined(__WXMSW__)
+		// Swap BGR for RGB for some random reason
+		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbBlue);
+		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbGreen);
 		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbRed);
+#else
+		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbRed);
 		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbGreen);
 		if (ok) ok = pFilter->Write(BMInfo->bmiColors[i].rgbBlue);
+#endif
 	}
 
 	// During the preparation process we told the system we would update by the
Index: Trunk/XaraLX/wxOil/pngutil.cpp
===================================================================
--- Trunk/XaraLX/wxOil/pngutil.cpp	(revision 893)
+++ Trunk/XaraLX/wxOil/pngutil.cpp	(revision 894)
@@ -244,7 +244,7 @@
 	png_structp png_ptr		= 0;	// Must be zero to avoid bad free in case of exception
 	png_infop info_ptr		= 0;	// Must be zero to avoid bad free in case of exception
 
-	LPBYTE *ppbRowPointers	= 0;	// Must be zero to avoid bad free in case of exception
+	png_bytepp ppbRowPointers= 0;	// Must be zero to avoid bad free in case of exception
 
 	try {
 	/* Create and initialize the png_struct with the desired error handler


Xara