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

Add the option to set a Bitmap as ImageResource #7

Open
wants to merge 1 commit into
base: change-image-dynamically
Choose a base branch
from

Conversation

carlosen14
Copy link

you have these methods..

    /**
     * Changes the background image and its layout dimensions.
     */
    public void setImageResource(int imageResource, int imageWidth, int imageHeight) {
        bitmap = extractBitmapFromDrawable(getResources().getDrawable(imageResource));
        bitmapSrcRect = bitmapRect(bitmap);

        this.imageWidth = imageWidth;
        this.imageHeight = imageHeight;

        rebuildFitter();
    }

    private static Bitmap extractBitmapFromDrawable(Drawable drawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

But you have to pass the image as int from the resources, there's should be a way to set a Bitmap directly as ImageResource, i think it is possible and it is not a big deal, but i want to set it programmatically depending on the situation and it will be very helpful in my needs..

Great tool, by the way!!

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

Successfully merging this pull request may close these issues.

2 participants