Game Development Reference
In-Depth Information
The following code implements the Windows GDI+ image loader.
public class NativeLoader : AbstractLoader
{
public override Bitmap Load(string fileName)
{
try
{
return new Bitmap(Image.FromFile(fileName));
}
catch
{
return null;
}
}
public override Bitmap Load(MemoryStream stream)
{
try
{
stream.Position = 0;
return new Bitmap(Image.FromStream(stream));
}
catch
{
return null;
}
}
public NativeLoader(System.IntPtr contextHandle) : base(contextHandle) {}
}
NOTE
You will need to reference System.IO for the MemoryStream object, as well as System.Drawing
for the Bitmap object.
Managed Direct3D Loader
It is very easy to use Windows GDI+ to load images, unless, of course, the image
format is not supported. Image formats that are not supported by Windows GDI+
require a different loader to process any unsupported image formats, so we are pre-
sented with two possibilities.
 
Search Nedrilad ::




Custom Search