GithubHelp home page GithubHelp logo

Comments (4)

 avatar commented on August 29, 2024

thanks, but i already know how to scale pictures in imageview. my problem is the lazylist library scaling in this method:

//decodes image and scales it to reduce memory consumption
private Bitmap decodeFile(File f){
    try {
        //decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(new FileInputStream(f),null,o);

        //Find the correct scale value. It should be the power of 2.
        final int REQUIRED_SIZE=70;
        int width_tmp=o.outWidth, height_tmp=o.outHeight;
        int scale=1;
        while(true){
            if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
                break;
            width_tmp/=2;
            height_tmp/=2;
            scale*=2;
        }

        //decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize=scale;
        return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
    } catch (FileNotFoundException e) {}
    return null;
}

it seems as if the image is scaled BEFORE its cached. this is what i want to change.

from lazylist.

 avatar commented on August 29, 2024

What is the exact value i have to change?

Is it:
//Find the correct scale value. It should be the power of 2.
final int REQUIRED_SIZE=70;

Or:
int scale=1;

and how has this to be changed?

from lazylist.

thest1 avatar thest1 commented on August 29, 2024

You can just disable scaling if you don't need it.

//decodes image and scales it to reduce memory consumption
private Bitmap decodeFile(File f){
    try {
        return BitmapFactory.decodeStream(new FileInputStream(f));
    } catch (FileNotFoundException e) {}
    return null;
}

But if you have big images they'll take too much space in memory cache, don't forget about that.

from lazylist.

 avatar commented on August 29, 2024

thank you very much, this solves my issue!
keep doing such great work

from lazylist.

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.