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


Java BitmapResource.obtain方法代码示例

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


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

示例1: createScaledBitmapInto

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
private static <T> Bitmap createScaledBitmapInto(Context context, T model,
		int width, int height)
		throws BitmapDecodingException {
	final Bitmap rough = Downsampler.AT_LEAST
			.decode(getInputStreamForModel(context, model),
					Glide.get(context).getBitmapPool(),
					width, height, DecodeFormat.PREFER_RGB_565);

	final Resource<Bitmap> resource = BitmapResource
			.obtain(rough, Glide.get(context).getBitmapPool());
	final Resource<Bitmap> result =
			new FitCenter(context).transform(resource, width, height);

	if (result == null) {
		throw new BitmapDecodingException("unable to transform Bitmap");
	}
	return result.get();
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:19,代码来源:BitmapUtil.java

示例2: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
    Bitmap source = resource.get();

    int width = source.getWidth();
    int height = source.getHeight();

    Bitmap bitmap = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
    drawRoundRect(canvas, paint, width, height);
    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:17,代码来源:RoundedCornersTransformation.java

示例3: createScaledBitmapInto

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
private static <T> Bitmap createScaledBitmapInto(Context context, T model, int width, int height)
    throws BitmapDecodingException
{
  final Bitmap rough = Downsampler.AT_LEAST.decode(getInputStreamForModel(context, model),
                                                   Glide.get(context).getBitmapPool(),
                                                   width, height,
                                                   DecodeFormat.PREFER_RGB_565);

  final Resource<Bitmap> resource = BitmapResource.obtain(rough, Glide.get(context).getBitmapPool());
  final Resource<Bitmap> result   = new FitCenter(context).transform(resource, width, height);

  if (result == null) {
    throw new BitmapDecodingException("unable to transform Bitmap");
  }
  return result.get();
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:17,代码来源:BitmapUtil.java

示例4: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();

  Bitmap.Config config =
      source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
  Bitmap bitmap = mBitmapPool.get(width, height, config);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(width, height, config);
  }

  Canvas canvas = new Canvas(bitmap);
  ColorMatrix saturation = new ColorMatrix();
  saturation.setSaturation(0f);
  Paint paint = new Paint();
  paint.setColorFilter(new ColorMatrixColorFilter(saturation));
  canvas.drawBitmap(source, 0, 0, paint);

  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:24,代码来源:GrayscaleTransformation.java

示例5: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();

  Bitmap result = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
  if (result == null) {
    result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  }

  Drawable mask = Utils.getMaskDrawable(mContext, mMaskId);

  Canvas canvas = new Canvas(result);
  mask.setBounds(0, 0, width, height);
  mask.draw(canvas);
  canvas.drawBitmap(source, 0, 0, sMaskingPaint);

  return BitmapResource.obtain(result, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:22,代码来源:MaskTransformation.java

示例6: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();
  GPUImage gpuImage = new GPUImage(mContext);
  gpuImage.setImage(source);
  gpuImage.setFilter(mFilter);

  Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();

  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:12,代码来源:GPUFilterTransformation.java

示例7: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {

    Bitmap source = resource.get();

    int width = source.getWidth();
    int height = source.getHeight();

    Bitmap result = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
    if (result == null) {
        result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(result);
    canvas.drawBitmap(source, 0, 0, mMaskingPaint);
    canvas.drawColor(0x44000000);

    return BitmapResource.obtain(result, mBitmapPool);
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:20,代码来源:ImageUtil.java

示例8: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();
  int size = Math.min(source.getWidth(), source.getHeight());

  mWidth = (source.getWidth() - size) / 2;
  mHeight = (source.getHeight() - size) / 2;

  Bitmap.Config config =
      source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
  Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, config);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
  }

  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:18,代码来源:CropSquareTransformation.java

示例9: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();

  Bitmap bitmap = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  }

  Canvas canvas = new Canvas(bitmap);
  Paint paint = new Paint();
  paint.setAntiAlias(true);
  paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
  drawRoundRect(canvas, paint, width, height);
  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:20,代码来源:RoundedCornersTransformation.java

示例10: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();

  Bitmap bitmap = mBitmapPool.get(width, height, Bitmap.Config.RGB_565);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
  }

  Canvas canvas = new Canvas(bitmap);
  Paint paint = new Paint();
  paint.setAntiAlias(true);
  paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
  drawRoundRect(canvas, paint, width, height);
  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:20,代码来源:RoundedCornersTransformation.java

示例11: decode

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override public @Nullable Resource<Bitmap> decode(File file, int w, int h, Options options) throws IOException {
	ByteBuffer buffer = ByteBuffer.allocate(w * h * 4);
	FileInputStream stream = new FileInputStream(file);
	try {
		stream.getChannel().read(buffer);
	} finally {
		stream.close();
	}
	Bitmap result = Bitmap.createBitmap(w, h, Config.ARGB_8888);
	try {
		buffer.rewind();
		result.copyPixelsFromBuffer(buffer);
		return BitmapResource.obtain(result, pool);
	} catch (RuntimeException ex) {
		result.recycle();
		throw ex;
	}
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:19,代码来源:RawFileDecoder.java

示例12: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();

  Bitmap.Config config =
      source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
  Bitmap bitmap = mBitmapPool.get(width, height, config);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(width, height, config);
  }

  Canvas canvas = new Canvas(bitmap);
  Paint paint = new Paint();
  paint.setAntiAlias(true);
  paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
  canvas.drawBitmap(source, 0, 0, paint);

  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:GosuncnMobile,项目名称:BaseLibrary,代码行数:23,代码来源:ColorFilterTransformation.java

示例13: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public final Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth,
    int outHeight) {
  if (!Util.isValidDimensions(outWidth, outHeight)) {
    throw new IllegalArgumentException(
        "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
            + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  }
  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  Bitmap toTransform = resource.get();
  int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  Bitmap transformed = transform(context.getApplicationContext(), bitmapPool, toTransform, targetWidth, targetHeight);

  final Resource<Bitmap> result;
  if (toTransform.equals(transformed)) {
    result = resource;
  } else {
    result = BitmapResource.obtain(transformed, bitmapPool);
  }
  return result;
}
 
开发者ID:wasabeef,项目名称:glide-transformations,代码行数:23,代码来源:BitmapTransformation.java

示例14: decode

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> decode(FallbackGlideParams source, int width, int height) throws IOException {
    BitmapPool pool = Glide.get(context).getBitmapPool();
    Bitmap bitmap = pool.getDirty(mPictureSizeInPx, mPictureSizeInPx, Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(mPictureSizeInPx, mPictureSizeInPx, Bitmap.Config.ARGB_8888);
    }
    drawTextAndBgColorOnBitmap(bitmap, source);
    return BitmapResource.obtain(bitmap, pool);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:ContactPictureLoader.java

示例15: transform

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入方法依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
    Bitmap source = resource.get();
    int size = Math.min(source.getWidth(), source.getHeight());

    int width = (source.getWidth() - size) / 2;
    int height = (source.getHeight() - size) / 2;

    Bitmap bitmap = mBitmapPool.get(size, size, Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    BitmapShader shader =
            new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
    if (width != 0 || height != 0) {
        Matrix matrix = new Matrix();
        matrix.setTranslate(-width, -height);
        shader.setLocalMatrix(matrix);
    }
    paint.setShader(shader);
    paint.setAntiAlias(true);

    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);

    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:31,代码来源:BitmapCircleTransformation.java


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