本文整理汇总了Java中com.edmodo.cropper.util.ImageViewUtil类的典型用法代码示例。如果您正苦于以下问题:Java ImageViewUtil类的具体用法?Java ImageViewUtil怎么用?Java ImageViewUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageViewUtil类属于com.edmodo.cropper.util包,在下文中一共展示了ImageViewUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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() {
RectF rect = mImageView.getDisplayRect();
Matrix matrix = mImageView.getDisplayMatrix();
float photoViewScale = (float)Math.sqrt(ImageViewUtil.getXScale(matrix)*ImageViewUtil.getXScale(matrix) +
ImageViewUtil.getXSkew(matrix)*ImageViewUtil.getXSkew(matrix));
Matrix orgScaleMatrix = new Matrix(matrix);
orgScaleMatrix.postScale(1 / photoViewScale, 1 / photoViewScale);
// Log.i("Cropper", "width=" + Math.round(rect.width() / photoViewScale) + " height=" + Math.round(rect.height() / photoViewScale)
// + " bitmapWidth=" + mBitmap.getWidth());
Bitmap rotateBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), orgScaleMatrix, true);
// Get crop window position relative to the displayed image.
// Log.i("Cropper", "Edge.LEFT=" + Edge.LEFT.getCoordinate() + " rect.left=" + rect.left
// + "Edge.TOP=" + Edge.TOP.getCoordinate() + " rect.top=" + rect.top);
final float cropWindowX = Edge.LEFT.getCoordinate() -rect.left;
final float cropWindowY = Edge.TOP.getCoordinate() -rect.top;
final float cropWindowWidth = Edge.getWidth();
final float cropWindowHeight = Edge.getHeight();
// Scale the crop window position to the actual size of the Bitmap.
float actualCropX = cropWindowX / photoViewScale;
float actualCropY = cropWindowY / photoViewScale;
float actualCropWidth = cropWindowWidth / photoViewScale;
float actualCropHeight = cropWindowHeight / photoViewScale;
// Crop the subset from the original Bitmap.
// Log.i("Cropper", "actualCropX="+ actualCropX +" actualCropY=" + actualCropY
// + " actualCropWidth=" + actualCropWidth + " actualCropHeight=" + actualCropHeight
// + " photoViewScale=" + photoViewScale + " rotateBitmap.width=" + rotateBitmap.getWidth());
if(actualCropX < 0){
actualCropWidth += actualCropX;
actualCropX = 0;
}
if(actualCropY < 0){
actualCropHeight += actualCropY;
actualCropY = 0;
}
if(actualCropWidth <0 || actualCropHeight<0){
return null;
}
if(actualCropWidth + actualCropX> rotateBitmap.getWidth()){
actualCropWidth = rotateBitmap.getWidth() - actualCropX;
}
if(actualCropHeight + actualCropY> rotateBitmap.getHeight()){
actualCropHeight = rotateBitmap.getHeight() - actualCropY;
}
final Bitmap croppedBitmap = Bitmap.createBitmap(rotateBitmap,
(int) actualCropX,
(int) actualCropY,
(int) actualCropWidth,
(int) actualCropHeight);
return croppedBitmap;
}
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:63,代码来源:CropImageView.java
示例10: 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
示例11: 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
示例12: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论