Git Product home page Git Product logo

Comments (7)

dylanvdmerwe avatar dylanvdmerwe commented on September 27, 2024

And on Android I think this code can be changed from:

bitmap = await Task.Run(() => BitmapFactory.DecodeStream(sourceStream, noPadding, opts));

To

bitmap = await BitmapFactory.DecodeStreamAsync(sourceStream, noPadding, opts);

from splat.

anaisbetts avatar anaisbetts commented on September 27, 2024

@dylanvdmerwe Basically, the resize is a JPEG loader optimization that is present on certain platforms and not others; i.e. we never load the full uncompressed bitmap, then attempt to scale it down - because it's not present on iOS, we don't want to load a full size, blow available memory, then return you a scaled one. I do agree that this is a bit misleading API though

from splat.

dylanvdmerwe avatar dylanvdmerwe commented on September 27, 2024

I see what you mean. But the best we can do is wrap it in an autorelease pool for now? Rather than just ignore it.

                        using (var ns = new NSAutoreleasePool())
                        {
                            var data = NSData.FromStream(sourceStream);
                            var sourceImage = UIImage.LoadFromData(data);


                            UIGraphics.BeginImageContext(new SizeF(desiredWidth.Value, desiredHeight.Value));
                            sourceImage.Draw(new RectangleF(0, 0, desiredWidth.Value, desiredHeight.Value));
                            var resultImage = UIGraphics.GetImageFromCurrentImageContext();
                            UIGraphics.EndImageContext();
                            return resultImage;
                        }

from splat.

anaisbetts avatar anaisbetts commented on September 27, 2024

I'm not suuuuuper excited about that, any other ideas?

from splat.

dylanvdmerwe avatar dylanvdmerwe commented on September 27, 2024

I've done quite a bit of reading today about this and on iOS I do not see anything similar to the Win Phone or Android methods. But at least using a manual auto release pool the memory is quickly recovered. This is very similar to how you shrink images you've taken on the iPhone camera (high res) before sending them via the web.

But do check the change I suggested for Android above.

from splat.

anaisbetts avatar anaisbetts commented on September 27, 2024

But do check the change I suggested for Android above.

👍 on that, I think that must be a new method they added

from splat.

halfnelson avatar halfnelson commented on September 27, 2024

The android loader doesn't resize the image either, it is passing the desiredWidth and desiredHeight variables to the outHeight and outWidth parameters of the opts bag, these capture the size of the image, not modify.

from splat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.