ImageAttributes, SetColorKey, Windows and WindowsCE
WindowsCE supposedly should work under the windows (And I do need to run my program in Windows as well as CE).
However, when SetColorKey is used, it does work in WindowsCE and fails in Windows with "Out of Memory" exception. I found the solution (to add a Windows DLL with the following code) but I do not like it. Is there is a better way to deal with the problem?
publicstaticIntPtr CreateBitmap(IntPtr phBitmap1,IntPtr phBitmap2,int iLeft1,int iTop1,int iLeft2,int iTop2,int iSize)
{
Rectangle rect =newRectangle(0, 0, iSize, iSize);Bitmap pBitmap1 =Bitmap.FromHbitmap(phBitmap1);Bitmap pBitmap2 =Bitmap.FromHbitmap(phBitmap2);Bitmap pBitmapResult =newBitmap(iSize, iSize);Graphics g =Graphics.FromImage(pBitmapResult);ImageAttributes imgattr =newImageAttributes();imgattr.SetColorKey(
Color.White,Color.White);g.DrawImage(pBitmap2, rect, iLeft2, iTop2, iSize, iSize,
GraphicsUnit.Pixel);g.DrawImage(pBitmap1, rect, iLeft1, iTop1, iSize, iSize,
GraphicsUnit.Pixel, imgattr);return pBitmapResult.GetHbitmap();}

