Game Development Reference
In-Depth Information
function.SlimDX.Direct2D.Bitmap d2dBitmap =
null;
// Load the bitmap using the
System.Drawing.Bitmap class.
System.Drawing.Bitmap originalImage = new
System.Drawing.Bitmap(filename);
// Create a rectangle holding the size of
the bitmap image.
Rectangle bounds = new Rectangle(0, 0,
originalImage.Width, originalImage.Height);
// Lock the memory holding this bitmap so
that only we are allowed to mess with it.
System.Drawing.Imaging.BitmapData imageData
= originalImage.LockBits(bounds,
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
// Create a DataStream attached to the
bitmap.
SlimDX.DataStream dataStream = new
DataStream(imageData.Scan0, imageData.Stride *
imageData.Height, true, false);
// Set the pixel format and properties.
PixelFormat pFormat = new
PixelFormat(SlimDX.DXGI.Format.B8G8R8A8_UNorm,
AlphaMode.Premultiplied);
BitmapProperties bmpProperties = new
BitmapProperties();
bmpProperties.PixelFormat = pFormat;
// Copy the image data into a new
SlimDX.Direct2D.Bitmap object.
d2dBitmap = new
SlimDX.Direct2D.Bitmap(m_RenderTarget, new
Size(bounds.Width, bounds.Height), dataStream,
Search WWH ::




Custom Search