Replies: 1 comment
-
You can try using the pixel data directly. This is much easier through the One thing to not is that you will need to verify if this is RGB or BGR pixel ordering. You can do this by checking the color type. |
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 am using the following SkiaSharp code to apply a multiply effect (tint) from a given
tintColor
to the image and create a new SKBitmap with the applied tint:This is working fine, but it seems evident to me from the documentation here that there is some inefficiency.
In particular, the line
SKColor[] pixels = skBitmap.Pixels
copies the entire pixel data over into this array which is not necessary. I could alternatively create an empty array likeSKColor[] pixels = new SKColor[skBitmap.Width * skBitmap.Height]
and then fill this in the for loop by accessing theskBitmap
color data with pointers.However, I am having a hard time understanding how to use pointers to do this. I read the documentation linked above but the C# pointers and byte management of the colors is a bit above my head.
What might the for loop in this example look like if using pointers to reference the color data from
skBitmap
instead?Thanks for any help.
Beta Was this translation helpful? Give feedback.
All reactions