-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Background
Drawing a Bitmap in GDI+ has relatively poor performance, since the image is stored in a device-independent format. The CachedBitmap class stores an image in a format that is optimized for display on a particular device. Thus, rendering an image stored in a CachedBitmap is fast, because no processing time is spent converting the image to the format required by the display device. Naturally, such a capability can substantially improve graphics performance in many scenarios. However, for whatever reason, it's not directly usable from the System.Drawing APIs.
API Proposal
This API is derived from this page of the GDI+ flat API. (I don't know what GdipEmfToWmfBits is doing on that page, but System.Drawing doesn't support saving metafiles anyway.)
namespace System.Drawing.Imaging
{
+ public sealed class CachedBitmap : MarshalByRefObject, IDisposable
+ {
+ public CachedBitmap(Bitmap bitmap, Graphics graphics);
+ public void Dispose();
+ }
}
namespace System.Drawing
{
public sealed class Graphics : MarshalByRefObject, IDisposable, IDeviceContext
{
+ public void DrawCachedBitmap(CachedBitmap cachedBitmap, int x, int y);
}
}As an aside: currently, libgdiplus doesn't implement this functionality. I imagine it would be fine to just PNSE when not on Windows for now (or, alternatively, making it "lie" about being a CachedBitmap, and simply calling DrawImage from DrawCachedBitmap).