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

If I use setScale, when I move the image it gets cropped! #27

Open
silentw opened this issue Jun 12, 2012 · 0 comments
Open

If I use setScale, when I move the image it gets cropped! #27

silentw opened this issue Jun 12, 2012 · 0 comments

Comments

@silentw
Copy link

silentw commented Jun 12, 2012

If I use setScale(), I then try to move my image up and I can't move along all the picture, but only within the initial frame...

Also, after setting scale, if I move the image, it will return to the zoom set initially or to the zoom made by pinch2zoom... To fix this, I added this:

protected void handleUp() {

    multiTouch = false;

    currentScale = image.getScale(); //THIS

And leveraging the topic, how do I get the manipulated drawable from the view (without using DrawingCache, which gives me a picture with the size of the ImageView, and I want the picture's real size but cropped)?

Thanks in advance...

My code is the following:

gImageView = (GestureImageView) findViewById(R.id.image);
gImageView.setImageURI(Uri.parse(getIntent().getStringExtra("imagem")));
gImageView.setScaleType(ScaleType.CENTER_CROP);
gImageView.setMaxScale(maxScale);
gImageView.setMinScale(minScale);
gImageView.setRotation(rotation);
gImageView.setDrawingCacheEnabled(true);

zoomIn = (ImageView) findViewById(R.id.zoomin);
zoomOut = (ImageView) findViewById(R.id.zoomout);
rotateLeft = (ImageView) findViewById(R.id.rotateleft);
rotateRight = (ImageView) findViewById(R.id.rotateright);
btnNext = (Button) findViewById(R.id.btnNext);

zoomIn.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        if(!zoomInDisabled){
            if(minScale == -9999) minScale = gImageView.getScale();
            gImageView.setScale(gImageView.getScale()+0.2f);
            gImageView.redraw();
            if(Math.round(gImageView.getScale()) >= maxScale){
                gImageView.setScale(maxScale);
                zoomIn.setImageDrawable(getResources().getDrawable(R.drawable.imagecontrol_zoomin_disabled));
                zoomInDisabled = true;
            }
            if(zoomOutDisabled) {
                zoomOutDisabled = false;
                zoomOut.setImageDrawable(getResources().getDrawable(R.drawable.imagecontrol_zoomout));
            }
        }
    }
});

zoomOut.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        if(!zoomOutDisabled){
            gImageView.setScale(gImageView.getScale()-0.2f);
            gImageView.redraw();
            if(round(gImageView.getScale(),4,BigDecimal.ROUND_HALF_UP) <= minScale){
                gImageView.setScale(minScale);
                zoomOut.setImageDrawable(getResources().getDrawable(R.drawable.imagecontrol_zoomout_disabled));
                zoomOutDisabled = true;
            }
            if(zoomInDisabled) {
                zoomInDisabled = false;
                zoomIn.setImageDrawable(getResources().getDrawable(R.drawable.imagecontrol_zoomin));
            }
        }
    }
});
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

No branches or pull requests

1 participant