GithubHelp home page GithubHelp logo

gesture-imageview's People

Contributors

jasonpolites avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gesture-imageview's Issues

View does not re-layout if changing images

I just updated to the latest version from your repository for the scaleType support, and it broke a couple of things:

  1. if I set an image to a preview (e.g., a loading image) and then set it to a real image, the second image never shows up. I fixed this by forcing "layout = false" when the image changes. I also had to reset startingScale = -1.0f but for production you'd probably have to check if startingScale had been set in the xml or by your own code.

  2. the orientation detection (landscape vs. portrait) isn't sufficient to cause the image to be fully on the screen; at least, not for scaleType = fitCenter. For example, I have a "landscape" image and a "landscape" phone, but the image's height (the shorter dimension) is slightly larger than my phone's height. However, due to the orientation checking in the GestureImageView, the image is fit based on its width, which causes the top and bottom to appear cut off, instead of having vertical, black bars on the left and right edges and showing me the whole image. I had this working before I adopted your latest changes; when it was working, my setupCanvas function was this:

protected void setupCanvas(int measuredWidth, int measuredHeight, int orientation) {

    if(lastOrientation != orientation) {
        layout = false;
        lastOrientation = orientation;
    }

    if(drawable != null && !layout) {
        int imageWidth = getImageWidth();
        int imageHeight = getImageHeight();

        hWidth = Math.round(((float)imageWidth / 2.0f));
        hHeight = Math.round(((float)imageHeight / 2.0f));

        if(orientation == Configuration.ORIENTATION_LANDSCAPE) {
            displayHeight = measuredHeight;

            // Calc height based on width
            float ratio = (float) imageWidth / (float) imageHeight;

            displayWidth = Math.round( (float) displayHeight * ratio);

        }
        else {
            displayWidth = measuredWidth;

            // Calc height based on width
            float ratio = (float) imageHeight / (float) imageWidth;

            displayHeight = Math.round( (float) displayWidth * ratio) ;

        }

        startingScale = Math.min((float) measuredHeight / (float) imageHeight, (float) measuredWidth/ (float) imageWidth);

        scaleAdjust = startingScale;

        this.centerX = (float)measuredWidth / 2.0f;
        this.centerY = (float)measuredHeight / 2.0f;

        x = centerX;
        y = centerY;

        gestureImageViewTouchListener = new GestureImageViewTouchListener(this, measuredWidth, measuredHeight);
        gestureImageViewTouchListener.setMinScale(minScale * startingScale);
        gestureImageViewTouchListener.setMaxScale(maxScale * startingScale);

        drawable.setBounds(-hWidth,-hHeight,hWidth,hHeight);

        setOnTouchListener(gestureImageViewTouchListener);  

        layout = true;
    }
}

I think the line you care about is the one about math.min().

In the latest version, if I change the following in computeStartingScale():

   case CENTER_INSIDE:
            startingScale = Math.min((float) measuredHeight / (float) imageHeight, (float) measuredWidth/ (float) imageWidth);
            break;

...then it starts out scaled correctly, but if I zoom out, it resets to the no-vertical-bars zoom.

If I then take that value and assign it to both fitScaleHorizontal and fitScaleVertical (in effect, replacing them both with it--I called it fitScaleAbs) in both the view and the gesture listener, then it works as expected.

Enable zoom only in center

Hi! I've been looking around, but i haven't found a way to enable the zoom only in the center of the image, independently from where the pinch gesture took place. Could you give me any clue? Or is it not possible?

Thank you very much!

rotate the image

If i want to rotate this image,How can i do?
i find the answer.
but i rotate the image around 90 degrees,touch this image not smooth,why?

Portrait orientation starts out full-size on too-tall images

Hi there! Again. :)

I have an image that's bigger vertically than horizontally (as an example, a screenshot of an average-sized android device while sitting in portrait orientation, displayed on said device).

When I put the device into landscape mode showing the same image, it's scaled properly (initially displays a zoomed-out image on the screen, but the canvas takes up the whole available width).

When I put it into portrait mode, if I have any header or footer on the page, the image shows up zoomed in to fit its width on the screen, at the expense of cutting off the height.

Perhaps there's a way to implement the android:scaleType attribute? This may come as two different attributes for this view: one to indicate the scale type for the view bounds (i.e., whether the canvas should wrap to the initial sizing of the image) and one to indicate the initial display.

I could for example set the scaleType to fitCenter, and then choose whether I want the canvas to take all available space so I can zoom to full size, or I want it to collapse the canvas down to wrap the initial image.

Doesn't support dynamic image setting!

@jasonpolites

b1 = (Button) findViewById(R.id.b1);
b2 = (Button) findViewById(R.id.b2);
giv = (GestureImageView) findViewById(R.id.image);

b1.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View arg0) {
    giv.setImageResource(R.drawable.portrait);
   }
});

b2.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View arg0) {
    giv.setImageResource(R.drawable.square);
   }
  });

Making Animations

Hello,
I am modifying the double tap listener to use for zooming in and zooming out. I was wondering how to integrate my simple ZoomAnimation.

    public boolean update(GestureImageView view, long elapsedTime) {

        if (elapsedTime<duration){
            return true;
        }
        return false;
    }

Now I have to move and scale the image in the direction where the touch event occurred. How can I reuse your code to do so.

        if(doubleTapDetector.onTouchEvent(event)) {
            initialDistance = 0;
            lastScale = currentScale;
            //lastScale = image.getScale();;
            currentScale = image.getScale();;
            next.x = image.getImageX();
            next.y = image.getImageY();
            calculateBoundaries();
            image.animationStart(new ZoomAnimation());
        }

would you mind to give some hints on doing so reusing your code.

Thank you!

zoom control buttons

please could you add zoom control buttons for devices that do not support multi touch (there are a few running android 2.2)
they can be either the zoom controls provided within android or custom zoom in and out buttons.

any help asap would be appreciated
thanks

maxScale seems to be ignored

Hey everyone,

i am calling setMaxScale(10f); but the zooming stops at 1.45. Even if i comment out the line...

Am i missing anything?

Unable to setImageBitmap from AsyncTask.onPostExecute method

hi, I used AsyncTask to download image. But I failed to set the image for GestureImageView after the image was downloaded. The ImageView class from Android worked fine.

@OverRide
protected void onPostExecute(String result) {
super.onPostExecute(result);
mProgressDialog.dismiss();
Bitmap bmp = BitmapFactory.decodeFile(mImagePath);
mImageView.setImageBitmap(bmp); // I see a black screen
}

Zooming out happens in-place then snaps back to top-left corner

When zooming out on an image that does not take up the whole View, pinching will render the image smaller, in-place where I pinched it. After I let go, it snaps to the top-left corner of the view.

Can you tell I'm currently implementing stuff with this code? ;)

Expected behavior would be either:

-Once the scaled image size < view size, leave the top-left corner anchored and only zoom the bottom right corner toward it, or
-Leave the image where I pinched it, offset from the corner

CENTER_INSIDE and CENTER_CROP are completely off

The documentation states:

  • CENTER_CROP: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • CENTER_INSIDE: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).

I've highlighted the important parts.

Basically, CENTER_CROP is scaling images it shouldn't scale (where both dimensions are already larger than the ImageView) and CENTER_INSIDE is not scaling properly, since a large image can always be dragged in one dimension.

i am unable to remove zoom???

here is my scenario, in view pager user is in page 0 and user make a pinch zoom. then user fling to go page1 of view pager. if so i want to remove zoom in page0 so that user can see original image if fling back to page0 of view pager.

load from cloud

I have a default GestureImageView . when I load pic from cloud.I want pic to replace the default, it changed,but I still can see the old one.When I click, It show the picture from the cloud that I need.But I don not know Why I need click?

Preserve ImageView inheritance hierarchy?

I'm trying to make use of this library, which is exactly what I was looking for; but there are a million places in my code where I refer to ImageViews as ImageViews specifically, and since a GestureImageView doesn't extend ImageView, I need to create a whole bunch of overloaded function calls in order to continue using my existing code base.

I'm wondering why you've chosen not to extend ImageView.

For reference, there's this old project here (http://code.google.com/p/android-pinch/) that does extend ImageView and provides similar functionality. I don't know if it will be of use to you or if you've seen it before.

Using setScale seems to mess up internal state

Hey everyone,

in my app i have a button that will set the scale to 1.0 by calling setScale(1).
This doesn't work so i have to call redraw() afterwards.
This works for a short time. The image is adjusted. But as soon as i pan or zoom, it resets to its last zoom :(

Goddchen

Use with Gallery

Hi,

I'm trying to use this with the standard Gallery Widget, Zoom etc is working but I can't switch the images. Fling on Gallery is not called.

Any suggestions
Chris

Need help setting scale programmatically

Hi there and thanks so much for taking your time to help others and sharing your hard work. I am still quite new to android programming and I know this is probably silly and obvious, but how do I set the images zoom level on the first load if I wanted it to be zoomed to a certain location in the image at a particular scale? I've tried setscale(XXX) with different values for XXX and have tried to use the redraw() method (along with any others I thought might do it) but I can't figure it out. I know you're working to update the project tonight and I don't want to slow you down, but I'd appreciate it if you could help me out with this simple task (*doh) when you have a second. Thank you!

Permit user to alternate between one- and two-finger gestures before release?

Android's onTouch() method can receive multiple ACTION_DOWN and ACTION_UP events before terminating the current gesture event stream. It takes two fingers to pinch, correct? Both will result in ACTION_DOWN without an intervening ACTION_UP. There's no technical reason why the user shouldn't be allowed to use the pinch gesture to zoom into an image, and release only one digit, to pan around the image, put the lifted digit back onto the digitizing display and zoom in or out some more, and lift it again to finally pan the image to the point he was actually looking for. At least, as long as that point was within the borders of the display.

At this time, GestureImageViewTouchListener's member field multiTouch inhibits the class from recognizing drag gestures by the user if the user had pressed more than one digit on the display during the touch events stream.

I recommend eliminating multiTouch so the user can both pinch and drag the image without having to fully cease contact with the display.

setScale & setPosition problems

Using setScale and setPosition seems to work initially (imageview shows image at specified scale and position), but any touch interaction results in imageview immediately reverting to default position and scale.

May be related to #27 ,but @silentw's fix:

protected void handleUp() {
  multiTouch = false;
  currentScale = image.getScale(); //THIS

...doesn't solve the problem for me.

After much mucking about with setScale and setPosition it seems the problem lays in the touch listener not being set to match the view position and scale, the touch listener contains state that is dependent upon the imageview state ?

Based upon their respective .reset() methods (which are more comprehensive than the setScale and setPosition methods) I've added .setTo(...) methods to GestureImageView...

public void reset() {
  x = centerX;
  y = centerY;
  scaleAdjust = startingScale;
  if (gestureImageViewTouchListener != null) {
    gestureImageViewTouchListener.reset();
  }
  redraw();
}

public void setTo(float newX, float newY, float newScale) {
  x = newX;
  y = newY;
  scaleAdjust = newScale;
  if (gestureImageViewTouchListener != null) {
      gestureImageViewTouchListener.setTo(newX, newY, newScale);
  }
  redraw();
}

...and GestureImageViewTouchListener...

public void reset() {
  currentScale = startingScale;
  next.x = centerX;
  next.y = centerY;
  calculateBoundaries();
  image.setScale(currentScale);
  image.setPosition(next.x, next.y);
  image.redraw();
}

public void setTo(float newX, float newY, float newScale) {
  currentScale = newScale;
  next.x = newX;
  next.y = newY;
  calculateBoundaries();
  image.setScale(currentScale);
  image.setPosition(next.x, next.y);
  image.redraw();
}

Using these methods results in the imagview displaying at the new scale and position. If I drag the image and then zoom it works as expected. However, if I just zoom the image (without having first panned) it reverts to the default scale and position.

Before I throw more hours at this, any advice on likely directions to proceed in ?

Update of image source of GestureImageView

Hello,

I am doing some tests with the codes provided here, specifically with custom view GestureImageView, and using StandartImageProgrammatic as main activity. When trying to perform the update of the source image based on a condition, for example:

if (x = 1) {
view.setImageResource (R.drawable.first);
else {}
view.setImageResource (R.drawable.second);
}

if the original image is zoomed or/and scrolled, changing the original position, when app make the exchange of image source, it is reset to the original position without zoom, and centralized.

Is there a way to keep the position of the previous picture?

Sorry for bad english.

Thank you.

Gesturimageview scrolling issues

getScrollX and GetScrollY in return always zero so how can get the horizontal and vertical scroll value of GestureImageView as we can clalculate in scrollView

changing double tap behavior is not working

Hello,

I wanted to change the double tap behavior so instead of zooming out i wanted it to zoom in to a certain part of the drawable and change scale.

my code changes to DoubleTapListener are not considered and the view still zooms out as by default.

public boolean onDoubleTap(MotionEvent e) {
    int newScale= viewW/128;
    image.setPosition(100,100); 
    //image.redraw();
    return true;
}

Zoom to a certain point with zoom animation

Hello Jason.
I tried out your yesterdays commit. And i have question about the image view position change during animation.

What I want to achieve is to zoom in to a certain position so that my newX and newY are on displays top left corner.

this is what I was using in the doubletaplistener

float scale = calcScale(image);
int iH = image.getImageHeight();
int iW = image.getImageWidth();
int newX = Math.round((iW / 2 - 25) * scale);
int newY = Math.round((iH / 2 - 200) * scale);

image.setScale(scale);
image.setPosition(newX, newY);

I cant use this anymore like this and In the ZoomAnimation I cant see how you are setting the position of the imageview.

Cheers,

Vadimo

Another null pointer when setting null drawable

Just grabbed your latest code and it's perfect! It behaves exactly as I would expect. Bravo! :)

One small thing: I get an NPE in initImage if I set the Drawable to null (as is wise to do to when cleaning up after an Activity so as not to persist references).

Is there a way to zoom buttons on top of the GestureImageView?

I have a series of buttons on a graphic which are positioned in order that they correspond to a part of the graphic. When I zoom in or out, the buttons stay where they were. Is there a way to make them zoom with the background or is there a function in GestureImageView that would let me read the parameters by which to move them (x,y) position and height/width?

Display image from url

Hi sir!
Your library so heplful! i like it ๐Ÿ‘
Now, i need display image download from url!
Can you hepl me display and zoom this image with GestureImageView?
Thanks so much!

Using drawable resource is not supported

Hello Jason,

I changed from a simple drawable to a drawable resource

the result was that nothing was drawn but also there weren't any errors.

This is the setup:
main.xml

    <com.polites.android.GestureImageView
        android:id="@+id/my_id"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="0.9"
        android:adjustViewBounds="true"
        android:src="@drawable/simple_layer" />

drawable/simple_layer.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- <item -->
    <!-- android:id="@[+][package:]id/resource_name" -->
    <!-- android:bottom="dimension" -->
    <!-- android:drawable="@[package:]drawable/drawable_resource" -->
    <!-- android:left="dimension" -->
    <!-- android:right="dimension" -->
    <!-- android:top="dimension"/> -->

    <item android:src="@drawable/img1"/>
    <item android:src="@drawable/img2"/>
</layer-list>

I checked onDraw, onLayout and on onMessuere by directing directly to the parent imageview but in all cases id didn't change the result.

Do you have any ideas what it might be that caused not to display the drawables?

Landscape/portrait rotation messes up the display/zoom factors

When rotating the view while zoomed in, or even without zooming in, rotating and then zooming in, it messes up the internal state and the image becomes displaced and aligned to the left. I've tried fixing this, but have been unsuccesfull so far. You can reproduce the behaviour using the imageview-example. It does not matter which ScaleType you use, it happens with all of them.

Can anyone confirm if this is the case for you as well?

Gamepad scale and move

I wrote some code to support scaling and moving in an image in gesture-imageview using a gamepad. It works great with XBOX gamepad. Maybe it will also work for the Ouya gamepad, but I have to wait for mine before I can test this. :)

Those two methods belong in GestureImageView.java:

public PointF getTopLeft() {
    PointF topLeft = new PointF();
    int effectiveWidth = Math.round( (float) getImageWidth() * getScale() );
    int effectiveHeight = Math.round( (float) getImageHeight() * getScale() );
    float diff = (float)(effectiveWidth - displayWidth) / 2.0f;
    topLeft.x = centerX - diff;
    float diff2 = (float)(effectiveHeight - displayHeight) / 2.0f;
    topLeft.y = centerY - diff2;
    return topLeft;
}

public void AxisMoveAndScale(float scaleAxisValue, float xAxisValue, float yAxisValue) {
     float scale = startingScale + (scaleAxisValue * (15 - startingScale));          
     setScale(scale);

     PointF topLeft = getTopLeft();

     float x = centerX + (topLeft.x - centerX) * xAxisValue;
     float y = centerY + (topLeft.y - centerY) * yAxisValue;

     setPosition(x, y);
     redraw();
}

After that call the method from any activity like this:

public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
         if (event.getAction() == MotionEvent.ACTION_MOVE) {
             float scaleAxisValue = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
             float xAxisValue = event.getAxisValue(MotionEvent.AXIS_Z);
             float yAxisValue = event.getAxisValue(MotionEvent.AXIS_RZ);
             currentGestureImageView.AxisMoveAndScale(scaleAxisValue, xAxisValue, yAxisValue);
             return true;
         }
     }
    return super.onGenericMotionEvent(event);
}

All touch events consumed

It would be nice to return false on the ontouch method when the touch event was not consumed, for example when the edge of the panning has been reached or when the image is completely visible and scroll events come, this would allow parent views for example scrollviews to receive the touch event and move accordingly

Greetings

Bad scale in landscape screen orientation

I have problem with image scale in landscape mode, resolution 1080x1920px (1920x1080px in landscape). Image is also landscape with resolution 960x640px. Image should be resized by resized by height, but in this case image resized by width and I didn't see whole image (top and bottom). Please help whit this!

Null pointer when setting null drawable

I get a null pointer exception here:

protected boolean isRecycled() {
    if(drawable != null && drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable)drawable).getBitmap().isRecycled();
    }
    return false;
}

Presumably, getBitmap() is returning null despite the other conditions being satisfied.

viewpager support

Hello!

Everything is working charmly but i intend to extend the functionality.
I want to implement a function where the image is draggable and zoomable in a viewpager, viewpager is not pageable just when the edge of the image is on the screen (eg: fullscreen image or left or right side). The isZoomed function is working properly, so the viewpager control is the issue only. Any advice?

Thanks in advance!

Change picture of GestureImageView does not work.

setImageBitmap/setImageDrawable/setImageResource does not work when call continuously.

These functions works very well if you call only one time.
But if you call more than two time, the image disappeared.

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

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));
            }
        }
    }
});

Trying to make sense of position and scale values

Hi, I'm just having a bit of difficulty figuring out the values to use for scale and position. I'm using a GestureImageViewListener and logging the values provided to onScale() and onPosition(), but don't see how they relate to the actual area of the image which is being displayed.

For example, I've got a 960x720 bitmap being displayed in my GestureImageView, and the width of the view is the full width of the screen (on my test device, 720). When the image is loaded with ScaleType.CENTER_CROP, and I scroll the GestureImageView so that the top-left corner of the bitmap is displayed at the top-left corner of the view, I get position values of x=632, y=474 and scale value of 2.6333334. Could you please tell me what these numbers are actually referring to, as I can't seem to figure it out.

Thanks

Pan and zoom

There will be awsome if we can pan and zoom at same time!

What problem have this possible feature?

Cheers

GastureImageView scrolling issuse

in this example application everything is fine but i face one issues that i anable to find that how can i detect scroll of gasuterImageview

trying to use a recycled bitmap fail on ICS

Hello Jason,

I am using gesture image view with an ics device and get always a recycled bitmap error. On 2.1 devices there is no such error.

I created a condition to debug wehen I have a recycled bitmap but the if condition is never reached and isRecycled always returns false until I draw on the canvas
@OverRide
protected void onDraw(Canvas canvas) {
if(layout) {
if(drawable != null && !isRecycled()) {
canvas.save();

            float adjustedScale = scale * scaleAdjust;

            canvas.translate(x, y);

            if(rotation != 0.0f) {
                canvas.rotate(rotation);
            }

            if(adjustedScale != 1.0f) {
                canvas.scale(adjustedScale, adjustedScale);
            }

// get here if recycled
if ((drawable instanceof BitmapDrawable) && ((BitmapDrawable)drawable).getBitmap().isRecycled()){
log("recycled");
}else{
drawable.draw(canvas);
}
canvas.restore();
}

        if(drawLock.availablePermits() <= 0) {
            drawLock.release();
        }
    }
}

07-02 13:18:11.497: E/AndroidRuntime(2022): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@b48c3420
07-02 13:18:11.497: E/AndroidRuntime(2022): at android.graphics.Canvas.throwIfRecycled(Canvas.java:1038)
07-02 13:18:11.497: E/AndroidRuntime(2022): at android.graphics.Canvas.drawBitmap(Canvas.java:1142)
07-02 13:18:11.497: E/AndroidRuntime(2022): at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393)
07-02 13:18:11.497: E/AndroidRuntime(2022): at android.graphics.drawable.LayerDrawable.draw(LayerDrawable.java:345)
07-02 13:18:11.497: E/AndroidRuntime(2022): at com.polites.android.GestureImageView.onDraw(GestureImageView.java:287)

du you have an idea what it might be? Is the error related to canvas or the bitmap

best regards,

Unable to use in a ViewPager

My project has a web gallery where you can swipe through photos. It would be nice to have zooming and panning.

I tried setting the ViewPager's ontouchlistener, to the GestureImageView's TouchListener, but no success. Either nothing happens, or the images become black.

Any ideas?

Maintanenance of this utility

I notice this library is very useful but there has been no update in a long time. Is this being actively maintained?

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.