private Bitmap ExtendBitmapIfSmallerThanScreen(Bitmap source)
{
if ((source.Width < Factory.AGSEditor.CurrentGame.MinRoomWidth) ||
(source.Height < Factory.AGSEditor.CurrentGame.MinRoomHeight))
{
int newWidth = Math.Max(source.Width, Factory.AGSEditor.CurrentGame.MinRoomWidth);
int newHeight = Math.Max(source.Height, Factory.AGSEditor.CurrentGame.MinRoomHeight);
if (source.PixelFormat != System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
{
Bitmap paddedBmp = new Bitmap(newWidth, newHeight, source.PixelFormat);
Graphics g = Graphics.FromImage(paddedBmp);
g.Clear(Color.Black);
// Have to specify Width and Height to stop it using
// the DPI of the image and drawing at different size
g.DrawImage(source, 0, 0, source.Width, source.Height);
g.Dispose();
source.Dispose();
return paddedBmp;
}
else
{
return ExtendCanvasSizeOf8BitBitmap(source, newWidth, newHeight);
}
}
return source;
}