Java Code Examples for android.widget.ImageView#ScaleType

The following examples show how to use android.widget.ImageView#ScaleType . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ucar-weex-core   File: ImageDrawable.java    License: 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
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 3
Source Project: PhotoViewer   File: Util.java    License: 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 4
Source Project: CrossBow   File: WearImageRequest.java    License: 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 5
Source Project: libcommon   File: MatrixUtils.java    License: 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 6
public void setImageHeader(Bitmap background, int headerDPHeight, ImageView.ScaleType scaleType) {
    setImageHeader(background, scaleType);

    this.headerDPHeight = headerDPHeight;
}
 
Example 7
Source Project: sketch   File: ImageZoomFunction.java    License: Apache License 2.0 4 votes vote down vote up
public void setScaleType(@NonNull ImageView.ScaleType scaleType) {
    zoomer.setScaleType(scaleType);
}
 
Example 8
private static Matrix.ScaleToFit scaleTypeToScaleToFit(ImageView.ScaleType st) {
    // ScaleToFit enum to their corresponding Matrix.ScaleToFit values
    return sS2FArray[st.ordinal() - 1];
}
 
Example 9
Source Project: YImagePicker   File: Info.java    License: Apache License 2.0 4 votes vote down vote up
public ImageView.ScaleType getScaleType() {
    return ImageView.ScaleType.valueOf(mScaleType);
}
 
Example 10
public ImageView.ScaleType getScaleType() {
    return mImageView.getScaleType();
}
 
Example 11
Source Project: lottie-android   File: LottieDrawable.java    License: Apache License 2.0 4 votes vote down vote up
void setScaleType(ImageView.ScaleType scaleType) {
  this.scaleType = scaleType;
}
 
Example 12
Source Project: FireFiles   File: ImageUtils.java    License: 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 13
Source Project: sketch   File: ZoomScales.java    License: 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);
 
Example 14
Source Project: android-project-wo2b   File: IPhotoView.java    License: 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 15
/**
 * 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
/**
 * 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 Project: Social   File: IPhotoView.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
Example 18
Source Project: Nimingban   File: IPhotoView.java    License: 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 19
Source Project: monolog-android   File: IPhotoView.java    License: 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 20
Source Project: CrossBow   File: ImageDecoder.java    License: 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);
}