Anyone know about CachedBitmap?
I have been trying to make it work but am having weird unconsistant problems and cannot find any useful documentation on the CachedBitmap. Can someone point me to a site or something that teaches about this?
Code:
[DllImport("gdiplus.dll")]
public static extern int GdipCreateCachedBitmap(IntPtr pBmp, IntPtr pGraphics, ref IntPtr pCatchedBmp);
[DllImport("gdiplus.dll")]
public static extern int GdipDrawCachedBitmap(IntPtr pGraphics, IntPtr pCatchedBmp, int x, int y);
[DllImport("gdiplus.dll")]
public static extern int GdipDeleteCachedBitmap(IntPtr pCatchedBmp);
public class CachedBmp
{
Bitmap cachedBmp;
IntPtr pCachedBmp;
IntPtr pGrfi;
public CachedBmp(Bitmap b, Graphics g)
{
this.cachedBmp= b;
FieldInfo Bmpfi= typeof(Bitmap).GetField("nativeImage", BindingFlags.Instance | BindingFlags.NonPublic);
IntPtr pBmpfi= (IntPtr)Bmpfi.GetValue(this.cachedBmp);
FieldInfo Grfi= typeof(Graphics).GetField("nativeGraphics", BindingFlags.Instance | BindingFlags.NonPublic);
pGrfi= (IntPtr)Grfi.GetValue(g);
GdipCreateCachedBitmap(pBmpfi, pGrfi, ref pCachedBmp);
}
public int Draw(int x, int y)
{
return GdipDrawCachedBitmap(this.pGrfi, this.pCachedBmp, x, y);
}
public void Delete()
{
GdipDeleteCachedBitmap(this.pCachedBmp);
}
}