Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large Gray8 Bitmaps don't interpolate #432

Closed
jackkutilek opened this issue Jan 24, 2018 · 3 comments
Closed

Large Gray8 Bitmaps don't interpolate #432

jackkutilek opened this issue Jan 24, 2018 · 3 comments

Comments

@jackkutilek
Copy link

jackkutilek commented Jan 24, 2018

Bitmaps larger than 2^14 (16384) in width (and possibly height) are not interpolating when drawn at a smaller size. I noticed this with Gray8 bitmaps and Alpha8 image shaders, but I assume it happens with larger pixel formats too.

Here is a fiddle where it is working in skia: https://fiddle.skia.org/c/374657f33d440c8f81390d9f50a9374a
I ran the test on my computer with the latest Skia code and it worked as well. I tried to build SkiaSharp's fork of Skia but failed, so I wasn't able to test it there.

here is some SkiaSharp code which reproduces it:

        var surfaceWidth = 500;
        var surfaceHeight = 300;
        var surface = SKSurface.Create(surfaceWidth, surfaceHeight, SKColorType.Bgra8888, SKAlphaType.Premul);
        var canvas = surface.Canvas;
        canvas.Clear(new SKColor(255, 255, 255));

        var bitmapWidth = 16384;
        var bitmapHeight = 10;
        var pixels = Marshal.AllocHGlobal(new IntPtr(bitmapWidth * bitmapHeight));
        unsafe
        {
            var bytes = (byte*) pixels;
            for(long y = 0; y < bitmapHeight; y++)
            for (long x = 0; x < bitmapWidth; x++)
            {
                var index = y * bitmapWidth + x;
                if (x / 3 == y)
                    bytes[index] = 0;
                else
                    bytes[index] = 255;
            }
        }

        var info = new SKImageInfo(bitmapWidth, bitmapHeight, SKColorType.Gray8, SKAlphaType.Premul);
        var image = SKImage.FromPixels(info, pixels);

        var scale = .66f;
        canvas.Scale(scale, scale);

        var paint = new SKPaint();
        paint.FilterQuality = SKFilterQuality.High;
        canvas.DrawImage(image, SKRect.Create(bitmapWidth, bitmapHeight), paint);

        using (var stream = new FileStream("renderout.png", FileMode.OpenOrCreate, FileAccess.Write))
        using (var outimage = surface.Snapshot())
        using (var data = outimage.Encode(SKEncodedImageFormat.Png, 100))
            data.SaveTo(stream);

renderout

changing the image width to 16383 interpolates as expected:
renderout

VS bug #738683

@mattleibow
Copy link
Contributor

I still need to investigate this more thoroughly, but this may be relevant: https://groups.google.com/forum/#!topic/skia-discuss/UCg8Gtk6e7s

Copy link
Contributor

Hi @jackkutilek. We have added the status/try-latest-version label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@mattleibow
Copy link
Contributor

This is a super old issue, but I just tested this with the latest version and it does not appear to be happing. So yay!

Closing this for now, if anyone sees this issue again, please open a new issue with a repro sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants