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


Java BitmapResource类代码示例

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


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

示例1: transform

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

  // The drawable needs to be initialized with the correct width and height in order for a view
  // displaying it to end up with the right dimensions. Since our transformations may arbitrarily
  // modify the dimensions of our GIF, here we create a stand in for a frame and pass it to the
  // transformation to see what the final transformed dimensions will be so that our drawable can
  // report the correct intrinsic width and height.
  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  Bitmap firstFrame = drawable.getFirstFrame();
  Resource<Bitmap> bitmapResource = new BitmapResource(firstFrame, bitmapPool);
  Resource<Bitmap> transformed = wrapped.transform(context, bitmapResource, outWidth, outHeight);
  if (!bitmapResource.equals(transformed)) {
    bitmapResource.recycle();
  }
  Bitmap transformedFrame = transformed.get();

  drawable.setFrameTransformation(wrapped, transformedFrame);
  return resource;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:GifDrawableTransformation.java

示例2: 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:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:BitmapUtil.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:rafjordao,项目名称:Nird2,代码行数:19,代码来源:BitmapUtil.java

示例4: 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

示例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.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:open-android,项目名称:Glide-transformations,代码行数:23,代码来源:ColorFilterTransformation.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();

  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

示例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);
  }

  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

示例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();
  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

示例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 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

示例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.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

示例11: 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

示例12: decodeGifWrapper

import com.bumptech.glide.load.resource.bitmap.BitmapResource; //导入依赖的package包/类
private ImageWrapper decodeGifWrapper(InputStream bis, int width, int height) throws IOException {
    ImageWrapper result = null;
    Resource<GifDrawable> gifResource = gifDecoder.decode(bis, width, height);
    if (gifResource != null) {
        GifDrawable drawable = gifResource.get();
        // We can more efficiently hold Bitmaps in memory, so for static GIFs, try to return Bitmaps
        // instead. Returning a Bitmap incurs the cost of allocating the GifDrawable as well as the normal
        // Bitmap allocation, but since we can encode the Bitmap out as a JPEG, future decodes will be
        // efficient.
        if (drawable.getNumberOfFrames() > 1) {
            result = new ImageWrapper(null /*bitmapResource*/, gifResource);
        } else {
            Resource<Bitmap> bitmapResource = new BitmapResource(drawable.getCurrentFrame(), bitmapPool);
            result = new ImageWrapper(bitmapResource, null /*gifResource*/);
        }
    }
    return result;
}
 
开发者ID:dengyuhan,项目名称:GlidePlus,代码行数:19,代码来源:ImageWrapperResourceDecoder.java

示例13: 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

示例14: 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

示例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 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:kfarst,项目名称:WhisperTweetNothings,代码行数:20,代码来源:RoundedCornersTransformation.java


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