android touchimageview缩放已经缩放的图像?

时间:2014-03-16 01:48:20

标签: android imageview zoom scale touchimageview

我正在使用touchimageview来放大我的应用。当我缩放图像时,它似乎放大到缩放以适合想象视图而不是放大图像原始大小的图像。无论如何要解决这个问题吗?\

iv = new TouchImageView(c);         
        //Center the Image
        iv.setScaleType(ScaleType.CENTER);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            params.weight = 1.0f;
            params.gravity=Gravity.CENTER;
        iv.setLayoutParams(params);

        drawable = (AnimationDrawable)c.getResources().getDrawable(R.drawable.loading_animation);

        UrlImageViewHelper.setUrlDrawable(iv, url,drawable);

编辑:我在touchimageview类中找到了这个方法,但我不知道如何实现它来使用默认的缩放效果......

/**
 * Return a bitmap of the zoomed image. This method is different from getZoomedImage() because
 * it cuts the image directly from the drawable source, and thus, is not limited by the resolution
 * of the view. Not supported with FIT_XY.
 * @return bitmap of zoomed image
 */
public Bitmap getZoomedImageFromSource() {
    if (mScaleType == ScaleType.FIT_XY) {
        throw new UnsupportedOperationException("getZoomedImageFromSource() not supported with FIT_XY");
    }
    Bitmap bitmap = ((BitmapDrawable) getDrawable()).getBitmap();
    Rect r = getZoomedRect();
    if (r.width() <= 0 || r.height() <= 0) {
        return null;
    }
    return Bitmap.createBitmap(bitmap, r.left, r.top, r.width(), r.height());
}

0 个答案:

没有答案