android.widget.ImageView#ScaleType ( )源码实例Demo

下面列出了android.widget.ImageView#ScaleType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ucar-weex-core   文件: ImageDrawable.java
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);
}
 
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;
}
 
源代码3 项目: PhotoViewer   文件: Util.java
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;
}
 
源代码4 项目: CrossBow   文件: WearImageRequest.java
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;
}
 
源代码5 项目: libcommon   文件: MatrixUtils.java
/**
 * 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;
	}
}
 
public void setImageHeader(Bitmap background, int headerDPHeight, ImageView.ScaleType scaleType) {
    setImageHeader(background, scaleType);

    this.headerDPHeight = headerDPHeight;
}
 
源代码7 项目: sketch   文件: ImageZoomFunction.java
public void setScaleType(@NonNull ImageView.ScaleType scaleType) {
    zoomer.setScaleType(scaleType);
}
 
private static Matrix.ScaleToFit scaleTypeToScaleToFit(ImageView.ScaleType st) {
    // ScaleToFit enum to their corresponding Matrix.ScaleToFit values
    return sS2FArray[st.ordinal() - 1];
}
 
源代码9 项目: YImagePicker   文件: Info.java
public ImageView.ScaleType getScaleType() {
    return ImageView.ScaleType.valueOf(mScaleType);
}
 
源代码10 项目: VideoOS-Android-SDK   文件: ForegroundImageView.java
public ImageView.ScaleType getScaleType() {
    return mImageView.getScaleType();
}
 
源代码11 项目: lottie-android   文件: LottieDrawable.java
void setScaleType(ImageView.ScaleType scaleType) {
  this.scaleType = scaleType;
}
 
源代码12 项目: FireFiles   文件: ImageUtils.java
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;
}
 
源代码13 项目: sketch   文件: ZoomScales.java
/**
 * 重置
 */
void reset(@NonNull final Context context, @NonNull final Sizes sizes, @Nullable final ImageView.ScaleType scaleType, final float rotateDegrees, final boolean readMode);
 
源代码14 项目: android-project-wo2b   文件: IPhotoView.java
/**
 * 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);
 
源代码15 项目: RestVolley   文件: RestVolleyImageLoader.java
/**
 * 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);
}
 
/**
 * 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);
 
源代码17 项目: Social   文件: IPhotoView.java
/**
 * Return the current scale type in use by the ImageView.
 */
ImageView.ScaleType getScaleType();
 
源代码18 项目: Nimingban   文件: IPhotoView.java
/**
 * Return the current scale type in use by the ImageView.
 *
 * @return current ImageView.ScaleType
 */
ImageView.ScaleType getScaleType();
 
源代码19 项目: monolog-android   文件: IPhotoView.java
/**
 * 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);
 
源代码20 项目: CrossBow   文件: ImageDecoder.java
/**
 * 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);
}