void MakeWrittable()
{
// If the bitmap only has one reference, that reference is the one held by this instance, so
// no other image is referencing this one. In that case, the bitmap can be safely modified.
// On the other hand, if the bitmap is being referenced by another image, an local copy
// has to be made
if (NativeRef.ReferenceCount > 1) {
Backend = ToolkitEngine.ImageBackendHandler.CopyBitmap (Backend);
NativeRef.ReleaseReference (true);
NativeRef = new NativeImageRef (Backend, ToolkitEngine);
}
}
public void CopyArea (int srcX, int srcY, int width, int height, BitmapImage dest, int destX, int destY) { dest.MakeWrittable (); var nr = dest.NativeRef; do { InitForToolkit (nr.Toolkit); nr.Toolkit.ImageBackendHandler.CopyBitmapArea (Backend, srcX, srcY, width, height, nr.Backend, destX, destY); } while (nr != dest.NativeRef); }