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


Java Transformation.transform方法代码示例

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


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

示例1: getTransformedFrame

import com.bumptech.glide.load.Transformation; //导入方法依赖的package包/类
private Resource<Bitmap> getTransformedFrame(Bitmap currentFrame,
    Transformation<Bitmap> transformation, GifDrawable drawable) {
  // TODO: what if current frame is null?
  Resource<Bitmap> bitmapResource = factory.buildFrameResource(currentFrame, bitmapPool);
  Resource<Bitmap> transformedResource =
      transformation.transform(
          context, bitmapResource, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
  if (!bitmapResource.equals(transformedResource)) {
    bitmapResource.recycle();
  }
  return transformedResource;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ReEncodingGifResourceEncoder.java

示例2: onResourceDecoded

import com.bumptech.glide.load.Transformation; //导入方法依赖的package包/类
@Override
public Resource<Z> onResourceDecoded(Resource<Z> decoded) {
  Class<Z> resourceSubClass = getResourceClass(decoded);
  Transformation<Z> appliedTransformation = null;
  Resource<Z> transformed = decoded;
  if (dataSource != DataSource.RESOURCE_DISK_CACHE) {
    appliedTransformation = decodeHelper.getTransformation(resourceSubClass);
    transformed = appliedTransformation.transform(glideContext, decoded, width, height);
  }
  // TODO: Make this the responsibility of the Transformation.
  if (!decoded.equals(transformed)) {
    decoded.recycle();
  }

  final EncodeStrategy encodeStrategy;
  final ResourceEncoder<Z> encoder;
  if (decodeHelper.isResourceEncoderAvailable(transformed)) {
    encoder = decodeHelper.getResultEncoder(transformed);
    encodeStrategy = encoder.getEncodeStrategy(options);
  } else {
    encoder = null;
    encodeStrategy = EncodeStrategy.NONE;
  }

  Resource<Z> result = transformed;
  boolean isFromAlternateCacheKey = !decodeHelper.isSourceKey(currentSourceKey);
  if (diskCacheStrategy.isResourceCacheable(isFromAlternateCacheKey, dataSource,
      encodeStrategy)) {
    if (encoder == null) {
      throw new Registry.NoResultEncoderAvailableException(transformed.get().getClass());
    }
    final Key key;
    if (encodeStrategy == EncodeStrategy.SOURCE) {
      key = new DataCacheKey(currentSourceKey, signature);
    } else if (encodeStrategy == EncodeStrategy.TRANSFORMED) {
      key = new ResourceCacheKey(currentSourceKey, signature, width, height,
          appliedTransformation, resourceSubClass, options);
    } else {
      throw new IllegalArgumentException("Unknown strategy: " + encodeStrategy);
    }

    LockedResource<Z> lockedResult = LockedResource.obtain(transformed);
    deferredEncodeManager.init(key, encoder, lockedResult);
    result = lockedResult;
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:48,代码来源:DecodeJob.java

示例3: onResourceDecoded

import com.bumptech.glide.load.Transformation; //导入方法依赖的package包/类
@Override
public Resource<Z> onResourceDecoded(Resource<Z> decoded) {
  Class<Z> resourceSubClass = getResourceClass(decoded);
  Transformation<Z> appliedTransformation = null;
  Resource<Z> transformed = decoded;
  if (dataSource != DataSource.RESOURCE_DISK_CACHE) {
    appliedTransformation = decodeHelper.getTransformation(resourceSubClass);
    transformed = appliedTransformation.transform(glideContext, decoded, width, height);
  }
  // TODO: Make this the responsibility of the Transformation.
  if (!decoded.equals(transformed)) {
    decoded.recycle();
  }

  final EncodeStrategy encodeStrategy;
  final ResourceEncoder<Z> encoder;
  if (decodeHelper.isResourceEncoderAvailable(transformed)) {
    encoder = decodeHelper.getResultEncoder(transformed);
    encodeStrategy = encoder.getEncodeStrategy(options);
  } else {
    encoder = null;
    encodeStrategy = EncodeStrategy.NONE;
  }

  Resource<Z> result = transformed;
  boolean isFromAlternateCacheKey = !decodeHelper.isSourceKey(currentSourceKey);
  if (diskCacheStrategy.isResourceCacheable(isFromAlternateCacheKey, dataSource,
      encodeStrategy)) {
    if (encoder == null) {
      throw new Registry.NoResultEncoderAvailableException(transformed.get().getClass());
    }
    final Key key;
    if (encodeStrategy == EncodeStrategy.SOURCE) {
      key = new DataCacheKey(currentSourceKey, signature);
    } else if (encodeStrategy == EncodeStrategy.TRANSFORMED) {
      key =
          new ResourceCacheKey(
              decodeHelper.getArrayPool(),
              currentSourceKey,
              signature,
              width,
              height,
              appliedTransformation,
              resourceSubClass,
              options);
    } else {
      throw new IllegalArgumentException("Unknown strategy: " + encodeStrategy);
    }

    LockedResource<Z> lockedResult = LockedResource.obtain(transformed);
    deferredEncodeManager.init(key, encoder, lockedResult);
    result = lockedResult;
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:DecodeJob.java


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