Java Code Examples for android.widget.ImageView#ScaleType

The following examples show how to use android.widget.ImageView#ScaleType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageDrawable.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private static void updateShaderAndSize(@NonNull ImageView.ScaleType scaleType, int vWidth, int vHeight, ImageDrawable imageDrawable, BitmapShader bitmapShader) {
  Matrix matrix = createShaderMatrix(scaleType, vWidth, vHeight,
                                     imageDrawable.bitmapWidth,
                                     imageDrawable.bitmapHeight);
  int intrinsicWidth = vWidth, intrinsicHeight = vHeight;
  if (scaleType == ImageView.ScaleType.FIT_CENTER) {
    RectF bitmapRect = new RectF(0, 0, imageDrawable.bitmapWidth, imageDrawable.bitmapHeight), contentRect = new RectF();
    matrix.mapRect(contentRect, bitmapRect);
    intrinsicWidth = (int) contentRect.width();
    intrinsicHeight = (int) contentRect.height();
    matrix = createShaderMatrix(scaleType, intrinsicWidth, intrinsicHeight, imageDrawable
        .bitmapWidth, imageDrawable.bitmapHeight);
  }
  imageDrawable.setIntrinsicWidth(intrinsicWidth);
  imageDrawable.setIntrinsicHeight(intrinsicHeight);
  bitmapShader.setLocalMatrix(matrix);
}
 
Example 2
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * ImageView.ScaleTypeからMatrixUtils.ScaleTypeへ変換
 * @param scaleType
 * @return
 */
@NonNull
public static ScaleType fromImageViewScaleType(@NonNull final ImageView.ScaleType scaleType) {
	if (sScaleTypeMap.containsKey(scaleType)) {
		return sScaleTypeMap.get(scaleType);
	} else {
		return ScaleType.CENTER_CROP;
	}
}
 
Example 3
Source File: WearImageRequest.java    From CrossBow with Apache License 2.0 5 votes vote down vote up
public WearImageRequest(String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight, Bitmap.Config decodeConfig,
                        ImageView.ScaleType scaleType, Response.ErrorListener errorListener) {
    super(url, listener, maxWidth, maxHeight, decodeConfig, scaleType, errorListener);
    this.maxWidth = maxWidth;
    this.maxHeight = maxHeight;
    config = decodeConfig;
    this.scaleType = scaleType;
}
 
Example 4
Source File: Util.java    From PhotoViewer with Apache License 2.0 5 votes vote down vote up
static boolean isSupportedScaleType(final ImageView.ScaleType scaleType) {
    if (scaleType == null) {
        return false;
    }
    switch (scaleType) {
        case MATRIX:
            throw new IllegalStateException("Matrix scale type is not supported");
    }
    return true;
}
 
Example 5
Source File: ActivityTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static int scaleTypeToInt(ImageView.ScaleType scaleType) {
    for (int i = 0; i < SCALE_TYPE_VALUES.length; i++) {
        if (scaleType == SCALE_TYPE_VALUES[i]) {
            return i;
        }
    }
    return -1;
}
 
Example 6
Source File: MaterialNavImageActivity.java    From AdvancedMaterialDrawer with Apache License 2.0 4 votes vote down vote up
public void setImageHeader(Bitmap background, int headerDPHeight, ImageView.ScaleType scaleType) {
    setImageHeader(background, scaleType);

    this.headerDPHeight = headerDPHeight;
}
 
Example 7
Source File: ImageUtils.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static Bitmap getImageThumbnail(String path, int mMaxWidth, int mMaxHeight){
    Bitmap.Config mDecodeConfig = Bitmap.Config.RGB_565;
    ImageView.ScaleType mScaleType = ImageView.ScaleType.CENTER_CROP;

    File bitmapFile = new File(path);
    Bitmap bitmap = null;

    if (!bitmapFile.exists() || !bitmapFile.isFile()) {
        return bitmap;
    }

    BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
    decodeOptions.inInputShareable = true;
    decodeOptions.inPurgeable = true;
    decodeOptions.inPreferredConfig = mDecodeConfig;
    if (mMaxWidth == 0 && mMaxHeight == 0) {

        bitmap = BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
    } else {
        // If we have to resize this image, first get the natural bounds.
        decodeOptions.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
        int actualWidth = decodeOptions.outWidth;
        int actualHeight = decodeOptions.outHeight;

        // Then compute the dimensions we would ideally like to decode to.
        int desiredWidth = getResizedDimension(mMaxWidth, mMaxHeight,
                actualWidth, actualHeight, mScaleType);
        int desiredHeight = getResizedDimension(mMaxHeight, mMaxWidth,
                actualHeight, actualWidth, mScaleType);

        // Decode to the nearest power of two scaling factor.
        decodeOptions.inJustDecodeBounds = false;
        decodeOptions.inSampleSize = ImageUtils.findBestSampleSize(actualWidth, actualHeight, desiredWidth, desiredHeight);
        Bitmap tempBitmap = BitmapFactory.decodeFile(bitmapFile.getAbsolutePath(), decodeOptions);
        // If necessary, scale down to the maximal acceptable size.
        if (tempBitmap != null
                && (tempBitmap.getWidth() > desiredWidth || tempBitmap.getHeight() > desiredHeight)) {
            bitmap = Bitmap.createScaledBitmap(tempBitmap, desiredWidth,
                    desiredHeight, true);
            tempBitmap.recycle();
        } else {
            bitmap = tempBitmap;
        }

    }
    return bitmap;
}
 
Example 8
Source File: LottieDrawable.java    From lottie-android with Apache License 2.0 4 votes vote down vote up
void setScaleType(ImageView.ScaleType scaleType) {
  this.scaleType = scaleType;
}
 
Example 9
Source File: ForegroundImageView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public ImageView.ScaleType getScaleType() {
    return mImageView.getScaleType();
}
 
Example 10
Source File: Info.java    From YImagePicker with Apache License 2.0 4 votes vote down vote up
public ImageView.ScaleType getScaleType() {
    return ImageView.ScaleType.valueOf(mScaleType);
}
 
Example 11
Source File: ChangeOnlineImageTransition.java    From YcShareElement with Apache License 2.0 4 votes vote down vote up
private static Matrix.ScaleToFit scaleTypeToScaleToFit(ImageView.ScaleType st) {
    // ScaleToFit enum to their corresponding Matrix.ScaleToFit values
    return sS2FArray[st.ordinal() - 1];
}
 
Example 12
Source File: ImageZoomFunction.java    From sketch with Apache License 2.0 4 votes vote down vote up
public void setScaleType(@NonNull ImageView.ScaleType scaleType) {
    zoomer.setScaleType(scaleType);
}
 
Example 13
Source File: IPhotoView.java    From Social with Apache License 2.0 2 votes vote down vote up
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
Example 14
Source File: IPhotoView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Controls how the image should be resized or moved to match the size of the ImageView. Any
 * scaling or panning will happen within the confines of this {@link
 * android.widget.ImageView.ScaleType}.
 *
 * @param scaleType - The desired scaling mode.
 */
void setScaleType(ImageView.ScaleType scaleType);
 
Example 15
Source File: RestVolleyImageLoader.java    From RestVolley with Apache License 2.0 2 votes vote down vote up
/**
 * remove the specified uri image cache.
 * @param uri image uri
 * @param maxWidth max width
 * @param maxHeight max height
 * @param scaleType {@link android.widget.ImageView.ScaleType}
 */
public void removeCache(String uri, int maxWidth, int maxHeight, ImageView.ScaleType scaleType) {
    mImageLoader.removeCache(uri, maxWidth, maxHeight, scaleType);
}
 
Example 16
Source File: IPhotoView.java    From android-project-wo2b with Apache License 2.0 2 votes vote down vote up
/**
 * Controls how the image should be resized or moved to match the size of
 * the ImageView. Any scaling or panning will happen within the confines of
 * this {@link android.widget.ImageView.ScaleType}.
 *
 * @param scaleType - The desired scaling mode.
 */
void setScaleType(ImageView.ScaleType scaleType);
 
Example 17
Source File: IPhotoView.java    From Nimingban with Apache License 2.0 2 votes vote down vote up
/**
 * Return the current scale type in use by the ImageView.
 *
 * @return current ImageView.ScaleType
 */
ImageView.ScaleType getScaleType();
 
Example 18
Source File: IPhotoView.java    From monolog-android with MIT License 2 votes vote down vote up
/**
 * Controls how the image should be resized or moved to match the size of
 * the ImageView. Any scaling or panning will happen within the confines of
 * this {@link android.widget.ImageView.ScaleType}.
 *
 * @param scaleType - The desired scaling mode.
 */
void setScaleType(ImageView.ScaleType scaleType);
 
Example 19
Source File: ImageDecoder.java    From CrossBow with Apache License 2.0 2 votes vote down vote up
/**
 * Decode a byte array into a bitmap, this will try its best to reuse old bitmaps allocations and will scale the image to the max height or width passed in.
 *
 * @param data image to be decoded
 * @param config Bitmap config for decode into, Defaults to RGB_565 if null is passed.
 * @param maxWidth maxWidth to decode to.
 * @param maxHeight maxHeight to decode to.
 * @return decoded bitmap or null if an error occured without a parse error.
 * @throws ParseError
 */
public static Bitmap parseImage(@NonNull byte[] data, @Nullable Bitmap.Config config, ImageView.ScaleType scaleType, int maxWidth, int maxHeight) throws ParseError {
    return parseImage(null, data, config, scaleType, maxWidth, maxHeight);
}
 
Example 20
Source File: ZoomScales.java    From sketch with Apache License 2.0 2 votes vote down vote up
/**
 * 重置
 */
void reset(@NonNull final Context context, @NonNull final Sizes sizes, @Nullable final ImageView.ScaleType scaleType, final float rotateDegrees, final boolean readMode);