當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.get方法代碼示例

本文整理匯總了Java中com.bumptech.glide.load.engine.Resource.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.get方法的具體用法?Java Resource.get怎麽用?Java Resource.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.bumptech.glide.load.engine.Resource的用法示例。


在下文中一共展示了Resource.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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

示例2: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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

示例3: createScaledBitmapInto

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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.engine.Resource; //導入方法依賴的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(bitmapPool, toTransform, targetWidth, targetHeight);

  final Resource<Bitmap> result;
  if (toTransform.equals(transformed)) {
    result = resource;
  } else {
    result = BitmapResource.obtain(transformed, bitmapPool);
  }
  return result;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:BitmapTransformation.java

示例5: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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

示例6: testReturnsBitmapWithExactlyGivenDimensionsIfBitmapIsLargerThanTarget

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Test
public void testReturnsBitmapWithExactlyGivenDimensionsIfBitmapIsLargerThanTarget() {
  int expectedWidth = 75;
  int expectedHeight = 74;

  for (int[] dimens : new int[][] { new int[] { 800, 200 }, new int[] { 450, 100 },
      new int[] { 78, 78 } }) {
    Bitmap toTransform = Bitmap.createBitmap(dimens[0], dimens[1], Bitmap.Config.ARGB_4444);
    when(resource.get()).thenReturn(toTransform);

    Resource<Bitmap> result =
        centerCrop.transform(context, resource, expectedWidth, expectedHeight);
    Bitmap transformed = result.get();
    assertEquals(expectedWidth, transformed.getWidth());
    assertEquals(expectedHeight, transformed.getHeight());
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:CenterCropTest.java

示例7: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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

示例8: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Override
public Resource<Drawable> transform(Context context, Resource<Drawable> resource, int outWidth,
    int outHeight) {
  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  Drawable drawable = resource.get();
  Resource<Bitmap> bitmapResourceToTransform =
      DrawableToBitmapConverter.convert(bitmapPool, drawable, outWidth, outHeight);
  if (bitmapResourceToTransform == null) {
    if (isRequired) {
      throw new IllegalArgumentException("Unable to convert " + drawable + " to a Bitmap");
    } else {
      return resource;
    }
  }
  Resource<Bitmap> transformedBitmapResource =
      wrapped.transform(context, bitmapResourceToTransform, outWidth, outHeight);

  if (transformedBitmapResource.equals(bitmapResourceToTransform)) {
    transformedBitmapResource.recycle();
    return resource;
  } else {
    return newDrawableResource(context, transformedBitmapResource.get());
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:DrawableTransformation.java

示例9: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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: transcode

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<PictureDrawable>(drawable);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:SvgDrawableTranscoder.java

示例11: transform

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的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();
    int scaledWidth = width / mSampling;
    int scaledHeight = height / mSampling;

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

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        try {
            bitmap = RSBlur.blur(mContext, bitmap, mRadius);
        } catch (RSRuntimeException e) {
            bitmap = FastBlur.blur(bitmap, mRadius, true);
        }
    } else {
        bitmap = FastBlur.blur(bitmap, mRadius, true);
    }

    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:33,代碼來源:BlurTransformation.java

示例12: transcode

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Override
   public Resource<BitmapPaletteWrapper> transcode(Resource<Bitmap> bitmapResource) 
{
       Bitmap bitmap = bitmapResource.get();
       BitmapPaletteWrapper bitmapPaletteWrapper = new BitmapPaletteWrapper(bitmap, PaletteUtils.generatePalette(bitmap));
      
	return new BitmapPaletteResource(bitmapPaletteWrapper, bitmapPool);
   }
 
開發者ID:MSay2,項目名稱:Mire,代碼行數:9,代碼來源:BitmapPaletteTranscoder.java

示例13: transcode

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode, Options options) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<>(drawable);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:SvgDrawableTranscoder.java

示例14: transcode

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public Resource<Drawable> transcode(Resource<ImageWrapper> toTranscode) {
    ImageWrapper gifBitmap = toTranscode.get();
    Resource<Bitmap> bitmapResource = gifBitmap.getBitmapResource();

    final Resource<? extends Drawable> result;
    if (bitmapResource != null) {
        result = bitmapDrawableResourceTranscoder.transcode(bitmapResource);
    } else {
        result = gifBitmap.getGifResource();
    }
    // This is unchecked but always safe, anything that extends a Drawable can be safely cast to a Drawable.
    return (Resource<Drawable>) result;
}
 
開發者ID:dengyuhan,項目名稱:GlidePlus,代碼行數:16,代碼來源:ImageWrapperDrawableTranscoder.java

示例15: decode

import com.bumptech.glide.load.engine.Resource; //導入方法依賴的package包/類
@Nullable
@Override
public Resource<Bitmap> decode(Uri source, int width, int height, Options options)
    throws IOException {
  Resource<Drawable> drawableResource = drawableDecoder.decode(source, width, height, options);
  Drawable drawable = drawableResource.get();
  return DrawableToBitmapConverter.convert(bitmapPool, drawable, width, height);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:ResourceBitmapDecoder.java


注:本文中的com.bumptech.glide.load.engine.Resource.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。