当前位置: 首页>>代码示例>>Java>>正文


Java ImageViewUtil.getBitmapRectCenterInside方法代码示例

本文整理汇总了Java中com.edmodo.cropper.util.ImageViewUtil.getBitmapRectCenterInside方法的典型用法代码示例。如果您正苦于以下问题:Java ImageViewUtil.getBitmapRectCenterInside方法的具体用法?Java ImageViewUtil.getBitmapRectCenterInside怎么用?Java ImageViewUtil.getBitmapRectCenterInside使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.edmodo.cropper.util.ImageViewUtil的用法示例。


在下文中一共展示了ImageViewUtil.getBitmapRectCenterInside方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSizeChanged

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {

    if (mBitmap != null) {
        final Rect bitmapRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, this);
        mCropOverlayView.setBitmapRect(bitmapRect);
    } else {
        mCropOverlayView.setBitmapRect(EMPTY_RECT);
    }
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:11,代码来源:CropImageView.java

示例2: getCroppedImage

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
/**
 * Gets the cropped image based on the current crop window.
 *
 * @return a new Bitmap representing the cropped image
 */
public Bitmap getCroppedImage() {

    final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for width.
    final float actualImageWidth = mBitmap.getWidth();
    final float displayedImageWidth = displayedImageRect.width();
    final float scaleFactorWidth = actualImageWidth / displayedImageWidth;

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for height.
    final float actualImageHeight = mBitmap.getHeight();
    final float displayedImageHeight = displayedImageRect.height();
    final float scaleFactorHeight = actualImageHeight / displayedImageHeight;

    // Get crop window position relative to the displayed image.
    final float cropWindowX = Edge.LEFT.getCoordinate() - displayedImageRect.left;
    final float cropWindowY = Edge.TOP.getCoordinate() - displayedImageRect.top;
    final float cropWindowWidth = Edge.getWidth();
    final float cropWindowHeight = Edge.getHeight();

    // Scale the crop window position to the actual size of the Bitmap.
    final float actualCropX = cropWindowX * scaleFactorWidth;
    final float actualCropY = cropWindowY * scaleFactorHeight;
    final float actualCropWidth = cropWindowWidth * scaleFactorWidth;
    final float actualCropHeight = cropWindowHeight * scaleFactorHeight;

    // Crop the subset from the original Bitmap.
    final Bitmap croppedBitmap = Bitmap.createBitmap(mBitmap,
            (int) actualCropX,
            (int) actualCropY,
            (int) actualCropWidth,
            (int) actualCropHeight);

    return croppedBitmap;
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:43,代码来源:CropImageView.java

示例3: getActualCropRect

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
public RectF getActualCropRect()
{
    Rect rect = ImageViewUtil.getBitmapRectCenterInside(g, e);
    float f1 = (float)g.getWidth() / (float)rect.width();
    float f2 = (float)g.getHeight() / (float)rect.height();
    float f3 = Edge.LEFT.getCoordinate() - (float)rect.left;
    float f4 = Edge.TOP.getCoordinate() - (float)rect.top;
    float f5 = Edge.getWidth();
    float f6 = Edge.getHeight();
    float f7 = f3 * f1;
    float f8 = f4 * f2;
    float f9 = f7 + f1 * f5;
    float f10 = f8 + f2 * f6;
    return new RectF(Math.max(0.0F, f7), Math.max(0.0F, f8), Math.min(g.getWidth(), f9), Math.min(g.getHeight(), f10));
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:16,代码来源:CropImageView.java

示例4: getCroppedImage

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
public Bitmap getCroppedImage(int i1, int j1)
{
    if (g == null)
    {
        return null;
    }
    Rect rect = ImageViewUtil.getBitmapRectCenterInside(g, e);
    float f1 = (float)g.getWidth() / (float)rect.width();
    float f2 = (float)g.getHeight() / (float)rect.height();
    float f3 = Edge.LEFT.getCoordinate() - (float)rect.left;
    float f4 = Edge.TOP.getCoordinate() - (float)rect.top;
    float f5 = Edge.getWidth();
    float f6 = Edge.getHeight();
    float f7 = f3 * f1;
    float f8 = f4 * f2;
    float f9 = f5 * f1;
    float f10 = f6 * f2;
    Debug.i("CropImageView", (new StringBuilder()).append(", actualCropWidth=").append(f9).append(", actualCropHeight=").append(f10).toString());
    if (f9 < 100F || f10 < 100F)
    {
        return g;
    }
    Matrix matrix = new Matrix();
    if ((float)i1 < f9 || (float)j1 < f10)
    {
        float f11 = (float)i1 / f9;
        float f12 = (float)j1 / f10;
        Debug.i("CropImageView", (new StringBuilder()).append("scaleWidth = ").append(f11).append(", scaleHeight=").append(f12).toString());
        matrix.postScale(f11, f12);
    }
    return Bitmap.createBitmap(g, (int)f7, (int)f8, (int)f9, (int)f10, matrix, false);
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:33,代码来源:CropImageView.java

示例5: onSizeChanged

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
protected void onSizeChanged(int i1, int j1, int k1, int l1)
{
    if (g != null)
    {
        Rect rect = ImageViewUtil.getBitmapRectCenterInside(g, this);
        f.setBitmapRect(rect);
        return;
    } else
    {
        f.setBitmapRect(a);
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:14,代码来源:CropImageView.java

示例6: getCroppedImage

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
/**
 * Gets the cropped image based on the current crop window.
 * 
 * @return a new Bitmap representing the cropped image
 */
public Bitmap getCroppedImage() {

    final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for width.
    final float actualImageWidth = mBitmap.getWidth();
    final float displayedImageWidth = displayedImageRect.width();
    final float scaleFactorWidth = actualImageWidth / displayedImageWidth;

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for height.
    final float actualImageHeight = mBitmap.getHeight();
    final float displayedImageHeight = displayedImageRect.height();
    final float scaleFactorHeight = actualImageHeight / displayedImageHeight;

    // Get crop window position relative to the displayed image.
    final float cropWindowX = Edge.LEFT.getCoordinate() - displayedImageRect.left;
    final float cropWindowY = Edge.TOP.getCoordinate() - displayedImageRect.top;
    final float cropWindowWidth = Edge.getWidth();
    final float cropWindowHeight = Edge.getHeight();

    // Scale the crop window position to the actual size of the Bitmap.
    final float actualCropX = cropWindowX * scaleFactorWidth;
    final float actualCropY = cropWindowY * scaleFactorHeight;
    final float actualCropWidth = cropWindowWidth * scaleFactorWidth;
    final float actualCropHeight = cropWindowHeight * scaleFactorHeight;

    // Crop the subset from the original Bitmap.
    final Bitmap croppedBitmap = Bitmap.createBitmap(mBitmap,
                                                     (int) actualCropX,
                                                     (int) actualCropY,
                                                     (int) actualCropWidth,
                                                     (int) actualCropHeight);

    return croppedBitmap;
}
 
开发者ID:qbeenslee,项目名称:Nepenthes-Android,代码行数:43,代码来源:CropImageView.java

示例7: onMeasure

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    if (mBitmap != null) {

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        // Bypasses a baffling bug when used within a ScrollView, where
        // heightSize is set to 0.
        if (heightSize == 0)
            heightSize = mBitmap.getHeight();

        int desiredWidth;
        int desiredHeight;

        double viewToBitmapWidthRatio = Double.POSITIVE_INFINITY;
        double viewToBitmapHeightRatio = Double.POSITIVE_INFINITY;

        // Checks if either width or height needs to be fixed
        if (widthSize < mBitmap.getWidth()) {
            viewToBitmapWidthRatio = (double) widthSize / (double) mBitmap.getWidth();
        }
        if (heightSize < mBitmap.getHeight()) {
            viewToBitmapHeightRatio = (double) heightSize / (double) mBitmap.getHeight();
        }

        // If either needs to be fixed, choose smallest ratio and calculate
        // from there
        if (viewToBitmapWidthRatio != Double.POSITIVE_INFINITY || viewToBitmapHeightRatio != Double.POSITIVE_INFINITY) {
            if (viewToBitmapWidthRatio <= viewToBitmapHeightRatio) {
                desiredWidth = widthSize;
                desiredHeight = (int) (mBitmap.getHeight() * viewToBitmapWidthRatio);
            } else {
                desiredHeight = heightSize;
                desiredWidth = (int) (mBitmap.getWidth() * viewToBitmapHeightRatio);
            }
        }

        // Otherwise, the picture is within frame layout bounds. Desired
        // width is
        // simply picture size
        else {
            desiredWidth = mBitmap.getWidth();
            desiredHeight = mBitmap.getHeight();
        }

        int width = getOnMeasureSpec(widthMode, widthSize, desiredWidth);
        int height = getOnMeasureSpec(heightMode, heightSize, desiredHeight);

        mLayoutWidth = width;
        mLayoutHeight = height;

        final Rect bitmapRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap.getWidth(),
                mBitmap.getHeight(),
                mLayoutWidth,
                mLayoutHeight);
        mCropOverlayView.setBitmapRect(bitmapRect);

        // MUST CALL THIS
        setMeasuredDimension(mLayoutWidth, mLayoutHeight);

    } else {

        mCropOverlayView.setBitmapRect(EMPTY_RECT);
        setMeasuredDimension(widthSize, heightSize);
    }
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:73,代码来源:CropImageView.java

示例8: getActualCropRect

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
/**
 * Gets the crop window's position relative to the source Bitmap (not the image
 * displayed in the CropImageView).
 *
 * @return a RectF instance containing cropped area boundaries of the source Bitmap
 */
public RectF getActualCropRect() {

    final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for width.
    final float actualImageWidth = mBitmap.getWidth();
    final float displayedImageWidth = displayedImageRect.width();
    final float scaleFactorWidth = actualImageWidth / displayedImageWidth;

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for height.
    final float actualImageHeight = mBitmap.getHeight();
    final float displayedImageHeight = displayedImageRect.height();
    final float scaleFactorHeight = actualImageHeight / displayedImageHeight;

    // Get crop window position relative to the displayed image.
    final float displayedCropLeft = Edge.LEFT.getCoordinate() - displayedImageRect.left;
    final float displayedCropTop = Edge.TOP.getCoordinate() - displayedImageRect.top;
    final float displayedCropWidth = Edge.getWidth();
    final float displayedCropHeight = Edge.getHeight();

    // Scale the crop window position to the actual size of the Bitmap.
    float actualCropLeft = displayedCropLeft * scaleFactorWidth;
    float actualCropTop = displayedCropTop * scaleFactorHeight;
    float actualCropRight = actualCropLeft + displayedCropWidth * scaleFactorWidth;
    float actualCropBottom = actualCropTop + displayedCropHeight * scaleFactorHeight;

    // Correct for floating point errors. Crop rect boundaries should not
    // exceed the source Bitmap bounds.
    actualCropLeft = Math.max(0f, actualCropLeft);
    actualCropTop = Math.max(0f, actualCropTop);
    actualCropRight = Math.min(mBitmap.getWidth(), actualCropRight);
    actualCropBottom = Math.min(mBitmap.getHeight(), actualCropBottom);

    final RectF actualCropRect = new RectF(actualCropLeft,
            actualCropTop,
            actualCropRight,
            actualCropBottom);

    return actualCropRect;
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:49,代码来源:CropImageView.java

示例9: getActualCropRect

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
/**
 * Gets the crop window's position relative to the source Bitmap (not the image
 * displayed in the CropImageView).
 * 
 * @return a RectF instance containing cropped area boundaries of the source Bitmap
 */
public RectF getActualCropRect() {

    final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for width.
    final float actualImageWidth = mBitmap.getWidth();
    final float displayedImageWidth = displayedImageRect.width();
    final float scaleFactorWidth = actualImageWidth / displayedImageWidth;

    // Get the scale factor between the actual Bitmap dimensions and the
    // displayed dimensions for height.
    final float actualImageHeight = mBitmap.getHeight();
    final float displayedImageHeight = displayedImageRect.height();
    final float scaleFactorHeight = actualImageHeight / displayedImageHeight;

    // Get crop window position relative to the displayed image.
    final float displayedCropLeft = Edge.LEFT.getCoordinate() - displayedImageRect.left;
    final float displayedCropTop = Edge.TOP.getCoordinate() - displayedImageRect.top;
    final float displayedCropWidth = Edge.getWidth();
    final float displayedCropHeight = Edge.getHeight();

    // Scale the crop window position to the actual size of the Bitmap.
    float actualCropLeft = displayedCropLeft * scaleFactorWidth;
    float actualCropTop = displayedCropTop * scaleFactorHeight;
    float actualCropRight = actualCropLeft + displayedCropWidth * scaleFactorWidth;
    float actualCropBottom = actualCropTop + displayedCropHeight * scaleFactorHeight;

    // Correct for floating point errors. Crop rect boundaries should not
    // exceed the source Bitmap bounds.
    actualCropLeft = Math.max(0f, actualCropLeft);
    actualCropTop = Math.max(0f, actualCropTop);
    actualCropRight = Math.min(mBitmap.getWidth(), actualCropRight);
    actualCropBottom = Math.min(mBitmap.getHeight(), actualCropBottom);

    final RectF actualCropRect = new RectF(actualCropLeft,
                                           actualCropTop,
                                           actualCropRight,
                                           actualCropBottom);

    return actualCropRect;
}
 
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:49,代码来源:CropImageView.java

示例10: onMeasure

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
protected void onMeasure(int i1, int j1)
{
    int k1 = android.view.View.MeasureSpec.getMode(i1);
    int l1 = android.view.View.MeasureSpec.getSize(i1);
    int i2 = android.view.View.MeasureSpec.getMode(j1);
    int j2 = android.view.View.MeasureSpec.getSize(j1);
    if (g != null)
    {
        super.onMeasure(i1, j1);
        if (j2 == 0)
        {
            j2 = g.getHeight();
        }
        double d1;
        double d2;
        int k2;
        int l2;
        int i3;
        int j3;
        Rect rect;
        if (l1 < g.getWidth())
        {
            d1 = (double)l1 / (double)g.getWidth();
        } else
        {
            d1 = (1.0D / 0.0D);
        }
        if (j2 < g.getHeight())
        {
            d2 = (double)j2 / (double)g.getHeight();
        } else
        {
            d2 = (1.0D / 0.0D);
        }
        if (d1 != (1.0D / 0.0D) || d2 != (1.0D / 0.0D))
        {
            if (d1 <= d2)
            {
                l2 = (int)(d1 * (double)g.getHeight());
                k2 = l1;
            } else
            {
                k2 = (int)(d2 * (double)g.getWidth());
                l2 = j2;
            }
        } else
        {
            k2 = g.getWidth();
            l2 = g.getHeight();
        }
        i3 = a(k1, l1, k2);
        j3 = a(i2, j2, l2);
        i = i3;
        j = j3;
        rect = ImageViewUtil.getBitmapRectCenterInside(g.getWidth(), g.getHeight(), i, j);
        f.setBitmapRect(rect);
        setMeasuredDimension(i, j);
        return;
    } else
    {
        f.setBitmapRect(a);
        setMeasuredDimension(l1, j2);
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:66,代码来源:CropImageView.java

示例11: onMeasure

import com.edmodo.cropper.util.ImageViewUtil; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    if (mBitmap != null) {

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        // Bypasses a baffling bug when used within a ScrollView, where
        // heightSize is set to 0.
        if (heightSize == 0)
            heightSize = mBitmap.getHeight();

        int desiredWidth;
        int desiredHeight;

        double viewToBitmapWidthRatio = Double.POSITIVE_INFINITY;
        double viewToBitmapHeightRatio = Double.POSITIVE_INFINITY;

        // Checks if either width or height needs to be fixed
        if (widthSize < mBitmap.getWidth()) {
            viewToBitmapWidthRatio = (double) widthSize / (double) mBitmap.getWidth();
        }
        if (heightSize < mBitmap.getHeight()) {
            viewToBitmapHeightRatio = (double) heightSize / (double) mBitmap.getHeight();
        }

        // If either needs to be fixed, choose smallest ratio and calculate
        // from there
        if (viewToBitmapWidthRatio != Double.POSITIVE_INFINITY || viewToBitmapHeightRatio != Double.POSITIVE_INFINITY) {
            if (viewToBitmapWidthRatio <= viewToBitmapHeightRatio) {
                desiredWidth = widthSize;
                desiredHeight = (int) (mBitmap.getHeight() * viewToBitmapWidthRatio);
            } else {
                desiredHeight = heightSize;
                desiredWidth = (int) (mBitmap.getWidth() * viewToBitmapHeightRatio);
            }
        }

        // Otherwise, the picture is within frame layout bounds. Desired
        // width is
        // simply picture size
        else {
            desiredWidth = mBitmap.getWidth();
            desiredHeight = mBitmap.getHeight();
        }

        int width = getOnMeasureSpec(widthMode, widthSize, desiredWidth);
        int height = getOnMeasureSpec(heightMode, heightSize, desiredHeight);

        mLayoutWidth = width;
        mLayoutHeight = height;

        final Rect bitmapRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap.getWidth(),
                                                                        mBitmap.getHeight(),
                                                                        mLayoutWidth,
                                                                        mLayoutHeight);
        mCropOverlayView.setBitmapRect(bitmapRect);

        // MUST CALL THIS
        setMeasuredDimension(mLayoutWidth, mLayoutHeight);

    } else {

        mCropOverlayView.setBitmapRect(EMPTY_RECT);
        setMeasuredDimension(widthSize, heightSize);
    }
}
 
开发者ID:qbeenslee,项目名称:Nepenthes-Android,代码行数:73,代码来源:CropImageView.java


注:本文中的com.edmodo.cropper.util.ImageViewUtil.getBitmapRectCenterInside方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。