public static Bitmap DrawSurfImage(Surface surf, Color bgcolor, Bitmap pic, RDPGFX_POINT16 picPos)
{
Bitmap bitmap = new Bitmap(surf.Width, surf.Height);
Graphics g = Graphics.FromImage(bitmap);
SolidBrush pixelBrush = new SolidBrush(bgcolor);
g.FillRectangle(pixelBrush, 0, 0, surf.Width, surf.Height);
for (int x = picPos.x; (x < surf.Width) && (x < (picPos.x + pic.Width)); x++)
{
for (int y = picPos.y; (y < surf.Height) && (y < (picPos.y + pic.Height)); y++)
{
Color c = pic.GetPixel(x - picPos.x, y - picPos.y);
bitmap.SetPixel(x, y, c);
}
}
return bitmap;
}