excubo-ag / Blazor.Canvas

https://excubo-ag.github.io/Blazor.Canvas/
MIT License
217 stars 23 forks source link

Pixel manipulation #147

Closed jahnotto closed 3 years ago

jahnotto commented 3 years ago

Is pixel manipulation implemented yet? The sample refers to the Mozilla documentation. However, calling

await ctx.CreateImageDataAsync(512, 512);

just freezes the browser. I can't find any way to actually manipulate the pixel data either.

stefanloerwald commented 3 years ago

Hi @jahnotto,

the pixel manipulation API is implemented. However, createImageData is pretty much useless in the C# context, because you only get a reference to it back, but not the actual object. So you would need to use JS to modify the image data yourself. There are just situations where it is better to stick to JS than to try to move things to C#. The idea of this library is to implement the canvas API, not e.g. the ImageData API and all the other APIs of JS.

Why it freezes for you I can't say, because it never did that for me in testing. I'd need to see the browser logs to understand what's happening.

Hope that helps. Stefan

jahnotto commented 3 years ago

Thanks for the super quick reply! I'll try to do this specific part in JS instead.