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

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1024
Date       : Fri May 12 15:46:00 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/dibutil.cpp

Swap BGR-RGB of palette of default bitmap when we read it.


Diff:
Index: Trunk/XaraLX/wxOil/dibutil.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dibutil.cpp	(revision 1023)
+++ Trunk/XaraLX/wxOil/dibutil.cpp	(revision 1024)
@@ -981,7 +981,22 @@
 	if (SizeOfRGB==sizeof(RGBQUAD))
 	{		
 		// easy - standard Windows palette
+#ifdef __WXMSW__
 		File->read( Result, HowMany * (UINT32)SizeOfRGB );
+#else
+		// silly old OS2 format in chunks of three bytes
+		RGBQUAD rgbx;
+
+		// this isn't exactly efficient but it works, is endian-independent and reliable
+		while (HowMany--)
+		{
+			File->read( &rgbx, sizeof(RGBQUAD) );
+			Result->rgbBlue = rgbx.rgbRed;			// NOTE! We are swapping BGR for RGB
+			Result->rgbGreen = rgbx.rgbGreen;
+			Result->rgbRed = rgbx.rgbBlue;			// NOTE! We are swapping BGR for RGB
+			Result++;
+		}
+#endif
 	}
 	else if (SizeOfRGB==sizeof(RGBTRIPLE))
 	{
@@ -992,9 +1007,15 @@
 		while (HowMany--)
 		{
 			File->read( &rgb, sizeof(RGBTRIPLE) );
+#ifdef __WXMSW__
 			Result->rgbBlue = rgb.rgbtBlue;
 			Result->rgbGreen = rgb.rgbtGreen;
 			Result->rgbRed = rgb.rgbtRed;
+#else
+			Result->rgbBlue = rgb.rgbtRed;			// NOTE! We are swapping BGR for RGB
+			Result->rgbGreen = rgb.rgbtGreen;
+			Result->rgbRed = rgb.rgbtBlue;			// NOTE! We are swapping BGR for RGB
+#endif
 			Result++;
 		}
 	}


Xara