Index: SoftSurface.cpp
===================================================================
--- SoftSurface.cpp	(revision 1477)
+++ SoftSurface.cpp	(working copy)
@@ -228,7 +228,8 @@
 
 	case 1:
 
-		m_surfaceType = SURFACE_PALETTE_8BIT;
+		m_surfaceType = SURFACE_RGBA;
+		m_bytesPerPixel = 4;
 		break;
 
 	case 2:
@@ -332,6 +333,8 @@
 			}
 		}
 
+		ConvertCheckboardToAlpha(pImg);
+
 		if (GetSurfaceType() == SURFACE_RGBA)
 		{
 			if (GetAutoPremultiplyAlpha() && !GetHasPremultipliedAlpha())
@@ -344,12 +347,21 @@
 		//memset(pImg, 600, m_bytesPerPixel*GetWidth()*GetHeight());
 	} else if (srcBytesPerPixel == 1)
 	{
-	
+		//load the palette info.  Note:  Bitmaps are BGR format
+		int colors = 256;
+		if (bmpImageInfoCopy.ColorsUsed != 0)
+		{
+			//looks like they don't use all the colors available
+			colors = bmpImageInfoCopy.ColorsUsed;
+		}
+		byte *pPaletteData = (byte*)pBmpImageInfo + sizeof(BMPImageHeader);
+		LoadPaletteDataFromBMPMemory(pPaletteData, colors);
 		if (bmpImageInfoCopy.Compression == BMP_COMPRESSION_RLE8)
 		{
 #ifdef _DEBUG
 			LogMsg("RLE");
 #endif
+			byte* lTempData = new byte[bmpImageInfoCopy.Size];
 
 			if (!RLE8BitDecompress(m_pPixels, pPixelData, dataSize,bmpImageInfoCopy.Size))
 			{
@@ -358,24 +370,34 @@
 				m_surfaceType = SURFACE_NONE;
 				return false;
 			}
-		} else
-		{
-			memcpy(m_pPixels, pPixelData, dataSize);
+
+			delete[] lTempData;
+
+			// TODO
 		}
-
-		int colors = 256;
-		if (bmpImageInfoCopy.ColorsUsed != 0)
+		else
 		{
-			//looks like they don't use all the colors available
-			colors = bmpImageInfoCopy.ColorsUsed;
-		}
 
-		//load the palette info.  Note:  Bitmaps are BGR format
+			glColorBytes *pImg = (glColorBytes*)m_pPixels;
 
-		byte *pPaletteData = (byte*)pBmpImageInfo+sizeof(BMPImageHeader);
-		LoadPaletteDataFromBMPMemory(pPaletteData, colors);
+			int srcUsedPitch = m_width * srcBytesPerPixel;
+			int srcPitchOffset = 0;
+			while ((srcUsedPitch + srcPitchOffset) % 4) { srcPitchOffset++; } //what's needed to pad it to a 32 byte boundry
+			int totalPitch = srcUsedPitch + srcPitchOffset;
 
-	}else if (srcBytesPerPixel == 2)
+			for (int y = 0; y < m_height; y++)
+			{
+				for (int x = 0; x < m_width; x++)
+				{
+					byte pByte = pPixelData[((m_height - y - 1)*totalPitch) + x * 1];
+					pImg[y*m_width + x] = m_palette[pByte];
+				}
+			}
+			ConvertCheckboardToAlpha(pImg);
+		}
+
+	}
+	else if (srcBytesPerPixel == 2)
 	{
 		//convert 16 bit to 32
 		//LogMsg("16 bit");
@@ -384,7 +406,7 @@
 
 		int srcUsedPitch = m_width * srcBytesPerPixel;
 		int srcPitchOffset = 0;
-		while ((srcUsedPitch+srcPitchOffset)%2) {srcPitchOffset++;} //what's needed to pad it to a 16 byte boundry
+		while ((srcUsedPitch+srcPitchOffset)%2) {srcPitchOffset++;} //what's needed to pad it to a 16 bit boundry
 		int totalPitch = srcUsedPitch+srcPitchOffset;
 
 		for (int y=0; y < m_height; y++)
@@ -405,6 +427,8 @@
 				pImg[y*m_width+x] = GetFinalRGBAColorWithColorKey(glColorBytes(red, green, blue, 255));
 			}
 		}
+		
+		ConvertCheckboardToAlpha(pImg);
 
 		if (GetAutoPremultiplyAlpha() && !GetHasPremultipliedAlpha())
 		{
@@ -435,6 +459,8 @@
 			}
 		}
 
+		ConvertCheckboardToAlpha(pImg);
+
 		if (GetAutoPremultiplyAlpha() && !GetHasPremultipliedAlpha())
 		{
 			PreMultiplyAlpha();
@@ -464,6 +490,8 @@
 			}
 		}
 
+		ConvertCheckboardToAlpha(pImg);
+
 		if (GetAutoPremultiplyAlpha() && !GetHasPremultipliedAlpha())
 		{
 			PreMultiplyAlpha();
@@ -492,6 +520,175 @@
 	return true;
 }
 
+void SoftSurface::ConvertCheckboardToAlpha(glColorBytes * pImg)
+{
+	// Checkboard check - pass 1 - change white pixels
+	auto lWhite = glColorBytes(0, 0, 0, 0);
+	auto lBlack = glColorBytes(0, 0, 0, 255);
+	auto lGray_1 = glColorBytes(0, 0, 0, 32);
+	auto lGray_2 = glColorBytes(0, 0, 0, 64);
+	auto lGray_3 = glColorBytes(0, 0, 0, 96);
+	auto lGray_4 = glColorBytes(0, 0, 0, 128);
+	for (int y = 0; y < m_height; y++)
+	{
+		for (int x = 0; x < m_width; x++)
+		{
+			auto& lThisPixel = pImg[y*m_width + x];
+			if (lThisPixel.a == 0)
+			{
+				do
+				{
+					// Count black pixels surrounding the white pixel
+					int lBlackPixelCount = 0;
+					int lPretendBlackPixelCount = 0;
+
+					// Top
+					if (y > 0)
+					{
+						auto& lTopPixel = pImg[(y - 1)*m_width + x];
+						if (lTopPixel.Compare(lBlack))
+						{
+							lBlackPixelCount += 1;
+						}
+						else if (lTopPixel.a != 0)
+						{
+							// Onto the next pixel
+							break;
+						}
+					}
+					else
+					{
+						// Pretend like edge is black
+						lPretendBlackPixelCount += 1;
+					}
+
+					// Left
+					if (x > 0)
+					{
+						auto& lLeftPixel = pImg[(y)*m_width + (x - 1)];
+						if (lLeftPixel.Compare(lBlack))
+						{
+							lBlackPixelCount += 1;
+						}
+						else if (lLeftPixel.a != 0)
+						{
+							// Onto the next pixel
+							break;
+						}
+					}
+					else
+					{
+						// Pretend like edge is black
+						lPretendBlackPixelCount += 1;
+					}
+
+					// Down
+					if (y < (m_height - 1))
+					{
+						auto& lDownPixel = pImg[(y + 1)*m_width + (x)];
+						if (lDownPixel.Compare(lBlack))
+						{
+							lBlackPixelCount += 1;
+						}
+						else if (lDownPixel.a != 0)
+						{
+							// Onto the next pixel
+							break;
+						}
+					}
+					else
+					{
+						// Pretend like edge is black
+						lPretendBlackPixelCount += 1;
+					}
+
+					// Right
+					if (x < (m_width - 1))
+					{
+						auto& lRightPixel = pImg[(y)*m_width + (x + 1)];
+						if (lRightPixel.Compare(lBlack))
+						{
+							lBlackPixelCount += 1;
+						}
+						else if (lRightPixel.a != 0)
+						{
+							// Onto the next pixel
+							break;
+						}
+					}
+					else
+					{
+						// Pretend like edge is black
+						lPretendBlackPixelCount += 1;
+					}
+
+					if (lBlackPixelCount > 0)
+					{
+						lBlackPixelCount += lPretendBlackPixelCount;
+						if (lBlackPixelCount == 1)
+						{
+							memcpy(&pImg[(y)*m_width + (x)], &lGray_1, sizeof(glColorBytes));
+						}
+						else if (lBlackPixelCount == 2)
+						{
+							memcpy(&pImg[(y)*m_width + (x)], &lGray_2, sizeof(glColorBytes));
+						}
+						else if (lBlackPixelCount == 3)
+						{
+							memcpy(&pImg[(y)*m_width + (x)], &lGray_3, sizeof(glColorBytes));
+						}
+						else if (lBlackPixelCount == 4)
+						{
+							memcpy(&pImg[(y)*m_width + (x)], &lGray_4, sizeof(glColorBytes));
+						}
+					}
+				} while (0);
+			}
+		}
+	}
+
+	// Checkboard check - phase 2 - change black pixels
+	for (int y = 0; y < m_height; y++)
+	{
+		for (int x = 0; x < m_width; x++)
+		{
+			if (pImg[y*m_width + x].Compare(lBlack))
+			{
+				int lBlack = 0;
+				// Convert black to alpha if surrounded by white / grays
+
+				if ((y == 0 ||
+					pImg[(y - 1)*m_width + x].a == 0 ||
+					pImg[(y - 1)*m_width + x].Compare(lGray_1) ||
+					pImg[(y - 1)*m_width + x].Compare(lGray_2) ||
+					pImg[(y - 1)*m_width + x].Compare(lGray_3) ||
+					pImg[(y - 1)*m_width + x].Compare(lGray_4)) &&
+					(x == 0 ||
+					pImg[(y)*m_width + (x - 1)].a == 0 ||
+					pImg[(y)*m_width + (x - 1)].Compare(lGray_1) ||
+					pImg[(y)*m_width + (x - 1)].Compare(lGray_2) ||
+					pImg[(y)*m_width + (x - 1)].Compare(lGray_3) ||
+					pImg[(y)*m_width + (x - 1)].Compare(lGray_4)) &&
+					(y == m_height - 1 ||
+					pImg[(y + 1)*m_width + x].a == 0 ||
+					pImg[(y + 1)*m_width + x].Compare(lGray_1) ||
+					pImg[(y + 1)*m_width + x].Compare(lGray_2) ||
+					pImg[(y + 1)*m_width + x].Compare(lGray_3) ||
+					pImg[(y + 1)*m_width + x].Compare(lGray_4)) &&
+					(x == m_width - 1 ||
+					pImg[(y)*m_width + (x + 1)].a == 0 ||
+					pImg[(y)*m_width + (x + 1)].Compare(lGray_1) ||
+					pImg[(y)*m_width + (x + 1)].Compare(lGray_2) ||
+					pImg[(y)*m_width + (x + 1)].Compare(lGray_3) ||
+					pImg[(y)*m_width + (x + 1)].Compare(lGray_4)))
+				{
+					memcpy(&pImg[(y)*m_width + (x)], &lGray_4, sizeof(glColorBytes));
+				}
+			}
+		}
+	}
+}
+
 #define GL_RGBA8 0x8058
 bool SoftSurface::LoadRTTexture(byte *pMem)
 {
Index: SoftSurface.h
===================================================================
--- SoftSurface.h	(revision 1477)
+++ SoftSurface.h	(working copy)
@@ -163,6 +163,7 @@
 	bool RLE8BitDecompress(byte *pDst, byte *pSrc, int dstSize, int srcSize);
 	void PreMultiplyAlpha();
 	bool LoadBMPTexture(byte *pMem);
+	void ConvertCheckboardToAlpha(glColorBytes * pImg);
 	bool LoadRTTexture(byte *pMem);
 	void BlitRGBFromRGBA( int dstX, int dstY, SoftSurface *pSrc, int srcX /*= 0*/, int srcY /*= 0*/, int srcWidth /*= 0*/, int srcHeight /*= 0*/ );
 	void BlitRGBFromRGB( int dstX, int dstY, SoftSurface *pSrc, int srcX /*= 0*/, int srcY /*= 0*/, int srcWidth /*= 0*/, int srcHeight /*= 0*/ );
Index: Surface.h
===================================================================
--- Surface.h	(revision 1477)
+++ Surface.h	(working copy)
@@ -20,7 +20,13 @@
 	glColorBytes(){};
 	glColorBytes(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a) : r(_r), g(_g), b(_b), a(_a){};
 
-	bool Compare(const glColorBytes &c) {return *(int*)&r == *(int*)&c.r;} //I couldn't get == working on this struct, a weird GUID error under windows?!, so I did this..
+	bool Compare(const glColorBytes &c) 
+	{
+		return (r == c.r) &&
+			   (g == c.g) &&
+			   (b == c.b) &&
+			   (a == c.a);
+	} //I couldn't get == working on this struct, a weird GUID error under windows?!, so I did this..
 	GLubyte r,g,b,a;
 };
 
