These are chat archives for AvaloniaUI/Avalonia

30th
Nov 2017
Matthijs ter Woord
@mterwoord
Nov 30 2017 07:11
to me it makes perfect sense that it works like that....
danwalmsley
@danwalmsley
Nov 30 2017 12:09
@kekekeks hey man, I'm also trying to get data from an image onto WriteableBitmap
danwalmsley
@danwalmsley
Nov 30 2017 12:24
Iv just submitted AvaloniaUI/Avalonia#1293
which allows me to get pixel data from a normal bitmap... probably dangerous
but could this work?
Matthijs ter Woord
@mterwoord
Nov 30 2017 12:34
giving a pointer sounds dangerous
why not use a pixel[x,y] indexer which returns the color?
danwalmsley
@danwalmsley
Nov 30 2017 13:04
trying to avoid a getter and setter method for accessing and setting pixels
basically want to read and write a bit like this
unsafe
            {
                for (int y = 0; y < source.PixelHeight; ++y)
                {
                    byte* row = (byte*)pixelData + (y * stride);

                    int columnOffset = 0;

                    for (int x = 0; x < source.PixelWidth; ++x)
                    {
                        var (r, g, b, a) = filter.Transform((row[columnOffset], row[columnOffset + 1], row[columnOffset + 2], row[columnOffset + 3]));

                        row[columnOffset] = r;
                        row[columnOffset + 1] = g;
                        row[columnOffset + 2] = b;
                        row[columnOffset + 3] = a;

                        columnOffset += 4;
                    }
                }
            }
this takes like 300ms on a 4k image
and if I use my previous code which had like a getpixel (x, y) function
it took 10 seconds
because of the overhead of containly calling a method for each pixel
when you get and set it
if you have access to intptr you can also pass it to anything else, without having to do a copy
Matthijs ter Woord
@mterwoord
Nov 30 2017 13:10
hmm, makes sense
but how to figure out the byte format?
danwalmsley
@danwalmsley
Nov 30 2017 13:13
in my case I know it
but I guess it should be possible to add that to interface
Nikita Tsukanov
@kekekeks
Nov 30 2017 14:39
@danwalmsley we could probably provide a way of getting bitmap data as a copy
represented as ILockedFramebuffer interface
Matthijs ter Woord
@mterwoord
Nov 30 2017 18:02
any known issues with wayland?
Nikita Tsukanov
@kekekeks
Nov 30 2017 19:38
Popup positioning is broken
So I'm forcing GTK to use X11 for now