Replies: 1 comment
-
Mmm, it seems in this case, I could have used the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having trouble to understand the ownership of pixel memory.
For example, the following code always saves a correct image A, and mostly saves a corrupt image B, or crashes randomly (at least in 1.68.3):
Moving the
bm1
out of the loop fixes the problem, but now I would have to pass two bitmaps around, while surely it should be possible forbm1
andbm2
to share the same underlyingSkPixelRef
?As a temporary workaround, I'm going to copy the pixels, but I would like to know the general rule here.
From the code above, it feels natural that ownership is managed for you, since I'm not passing any
IntPtr
around. However, looking the native code,SKPixmap
doesn't store aSKPixelRef
, only a pointer...So the managed bit is just an illusion, even though I'm coding C# here, I still have to think carefully about C/C++ ownership?
As far as I understand, the rules are:
SKPixmap
never frees memory, it is purely a (non reference counted!) view on the raw pixels, using a pointerSKBitmap
andSKImage
internally use anSKPixelRef
(reference counted), but this reference counting is lost as soon as a pixmap is involved...Is this correct?
Beta Was this translation helpful? Give feedback.
All reactions