SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[FEATURE] Support new color mapping api

Open Shadowblitz16 opened this issue 1 year ago • 3 comments

Is your feature request related to a problem?

Skia dropped colormap support for some reason

Describe the solution you would like

Please supply alternative for mapping true color images to a linear color array.

It would be a way to map a true color image to a 32 bit index in a color array. Then it could be shifted and drawn remapped to the palette.

To make it clear this is 3 parts.

  1. A api to quantization rgba SKBitmaps to a 32 bit indexed SKBitmaps
  2. A api to shift color quantization palettes
  3. A api to draw it back to a palette mapped rgba SKBitmap

Describe alternatives you have considered

I tried using avalonia ui WriteableBitmaps but they are too slow.

Additional context

By 32 bit indexed image I mean it would still technically be a rgba image but the integer representation of the color would be used as the index to the color palette.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Shadowblitz16 avatar Jul 09 '24 20:07 Shadowblitz16

I wonder if this is better with a custom runtime effect / shader? Then you can just draw an image and the effect will be applied.

I am not super useful with writing shaders, but here are some things that may help:

  • intro docs: https://skia.org/docs/user/sksl/
  • playground: https://shaders.skia.org/

Here is a ShaderToy something that may help: https://www.shadertoy.com/view/XdX3D4

You might be able to do everything you want in a single shader

mattleibow avatar Jul 10 '24 10:07 mattleibow

@taublast I know you are doing cool things with shaders, is this something that you have done before?

mattleibow avatar Jul 10 '24 10:07 mattleibow

Not at all, but the above could be done with a shader indeed, that's maybe why Skia removed their API code.
Logically, upon SkiaSharp v3 release it would be totally up to us developers to provide an implementation for absolutely any image processing, as we would finally have that total powerful possibility in .NET. :)

taublast avatar Jul 10 '24 12:07 taublast