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


Java CloseableBitmap类代码示例

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


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

示例1: onNewResultImpl

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
@Override
public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (!dataSource.isFinished()) {
    return;
  }

  CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
  Bitmap bitmap = null;
  if (closeableImageRef != null &&
      closeableImageRef.get() instanceof CloseableBitmap) {
    bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
  }

  try {
    onNewResultImpl(bitmap);
  } finally {
    CloseableReference.closeSafely(closeableImageRef);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BaseBitmapDataSubscriber.java

示例2: onRun

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
@Override
public void onRun() throws Throwable {
  Log.i(TAG, "RUNNING UploadJob for Item["+itemId+"] Uri["+uri.toString()+"]");

  if(MediaUtils.isPhoto(UriUtils.extractMimeType(weakReference.get(), uri))) {
    DataSource<CloseableReference<CloseableImage>> dataSource = Fresco.getImagePipeline().fetchDecodedImage(ImageRequest.fromUri(uri), weakReference.get());
    Throwable failureCause = dataSource.getFailureCause();
    if (failureCause != null) {
      throw failureCause;
    }

    CloseableReference<CloseableImage> result = dataSource.getResult();
    if (result != null) {
      CloseableImage closeableImage = result.get();
      if (closeableImage instanceof CloseableBitmap) {
        Bitmap bitmap = ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
        uploadFile(createImageTempFile(bitmap));
      }
    }
  }else{
    uploadFile(new File(uri.getPath()));
  }
}
 
开发者ID:bnsantos,项目名称:android-upload-service,代码行数:24,代码来源:UploadJob.java

示例3: storeEntries

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
private void storeEntries(
    List<CountingMemoryCacheInspector.DumpInfoEntry<CacheKey, CloseableImage>>
        entries,
    int i,
    PrintStream writer,
    File directory) throws IOException {
  String filename;
  for (CountingMemoryCacheInspector.DumpInfoEntry<CacheKey, CloseableImage>
      entry : entries) {
      CloseableImage closeableImage = entry.value.get();
      if (closeableImage instanceof CloseableBitmap) {
        CloseableBitmap closeableBitmap = (CloseableBitmap) closeableImage;
        filename = "tmp" + i + ".png";
        writer.println(formatStrLocaleSafe(
            "Storing image %d as %s. Key: %s",
            i,
            filename,
            entry.key));
        storeImage(
            closeableBitmap.getUnderlyingBitmap(),
            new File(directory, filename),
            Bitmap.CompressFormat.PNG,
            100);
      } else {
        writer.println(formatStrLocaleSafe(
            "Image %d has unrecognized type %s. Key: %s",
            i,
            closeableImage,
            entry.key));
      }
    i++;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:BaseFrescoStethoPlugin.java

示例4: if

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
/**
 * Returns an unsafe bitmap reference. Do not assign the result of this method to anything other
 * than a local variable, or it will no longer work with the reference count goes to zero.
 */
/* package */ @Nullable Bitmap getBitmap() {
  if (mImageRef == null) {
    return null;
  }

  CloseableImage closeableImage = mImageRef.get();
  if (!(closeableImage instanceof CloseableBitmap)) {
    mImageRef.close();
    mImageRef = null;
    return null;
  }

  return ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:PipelineRequestHelper.java

示例5: onFinalImageSet

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
    super.onFinalImageSet(id, imageInfo, animatable);
    if (mLoadingListener != null && mImageView != null) {
        ImageView imageView = mImageView.get();
        if (imageInfo != null) {
            if (imageInfo instanceof CloseableBitmap) {
                mLoadingListener.onLoadingComplete(mImageUri, imageView, ((CloseableBitmap) imageInfo).getUnderlyingBitmap());
                return;
            }
        }
        mLoadingListener.onLoadingComplete(mImageUri, imageView, null);
    }
}
 
开发者ID:succlz123,项目名称:S1-Go,代码行数:15,代码来源:ImageLoader.java

示例6: getBitmapSizeBytes

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
private static int getBitmapSizeBytes(@Nullable CloseableImage image) {
  if (!(image instanceof CloseableBitmap)) {
    return 0;
  }
  return BitmapUtil.getSizeInBytes(((CloseableBitmap) image).getUnderlyingBitmap());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:FrescoFrameCache.java

示例7: onNewResultImpl

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
@Override
    public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
        if (!dataSource.isFinished()) {
            return;
        }

        CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
        Bitmap bitmap = null;
        if (closeableImageRef != null &&
                closeableImageRef.get() instanceof CloseableBitmap) {
            bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
        }


        if(bitmap!=null ){
            if(bitmap.isRecycled()){
                onFailure(dataSource);
            }else {
                onNewResultImpl(bitmap,dataSource);
            }
            return;
        }

//        //如果bitmap为空
//        File cacheFile  = ImageLoader.getActualLoader().getFileFromDiskCache(finalUrl);
//        if(cacheFile ==null){
//            onFailure(dataSource);
//            return;
//        }
//        //还要判断文件是不是gif格式的
//        if (!"gif".equalsIgnoreCase(MyUtil.getRealType(cacheFile))){
//            onFailure(dataSource);
//            return;
//        }
//        Bitmap bitmapGif = GifUtils.getBitmapFromGifFile(cacheFile);//拿到gif第一帧的bitmap
//        if(width>0 && height >0) {
//            bitmapGif = MyUtil.compressBitmap(bitmapGif, true, width, height);//将bitmap压缩到指定宽高。
//        }

//        if (bitmapGif != null) {
//            onNewResultImpl(bitmap,dataSource);
//        } else {
//            onFailure(dataSource);
//        }




       /* try {
            onNewResultImpl(bitmap);
        } finally {
            //CloseableReference.closeSafely(closeableImageRef);
        }*/
    }
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:55,代码来源:BaseBitmapDataSubscriber.java

示例8: onNewResult

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
@Override
public void onNewResult(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (!dataSource.isFinished()) {
    // only interested in final image, no need to close the dataSource
    return;
  }

  try {
    if (mDataSource != dataSource) {
      // Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
      return;
    }

    mDataSource = null;

    CloseableReference<CloseableImage> imageReference = dataSource.getResult();
    if (imageReference == null) {
      // Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
      return;
    }

    CloseableImage image = imageReference.get();
    if (!(image instanceof CloseableBitmap)) {
      // only bitmaps are supported
      imageReference.close();
      return;
    }

    mImageRef = imageReference;

    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
      // Shouldn't ever happen, but let's be safe.
      return;
    }

    BitmapUpdateListener listener = Assertions.assumeNotNull(mBitmapUpdateListener);
    listener.onBitmapReady(bitmap);
    listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD);
    listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
  } finally {
    dataSource.close();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:45,代码来源:PipelineRequestHelper.java

示例9: handleBitmap

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
private void handleBitmap(CloseableBitmap closeableBitmap, int position) {
    Bitmap bitmap = closeableBitmap.getUnderlyingBitmap();
    map.put(position, bitmap);

}
 
开发者ID:canyinghao,项目名称:CanPhotos,代码行数:6,代码来源:CanViewPagerActivity.java

示例10: getBitmapFromCache

import com.facebook.imagepipeline.image.CloseableBitmap; //导入依赖的package包/类
/**
 * 从Fresco的缓存中获取Bitmap
 * @return
 */
private Bitmap getBitmapFromCache(String imgUrl){

    Bitmap bm = null;

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(imgUrl))
            .build();


    DataSource<CloseableReference<CloseableImage>> dataSource =
            imagePipeline.fetchImageFromBitmapCache(request, this);
    try{
        CloseableReference<CloseableImage> imageReference = dataSource.getResult();
        if(imageReference != null){
            try{
                // do something
                CloseableImage image = imageReference.get();
                if(image instanceof CloseableBitmap){

                    Bitmap bitmap = ((CloseableBitmap)image).getUnderlyingBitmap();

                    Log.i(TAG, "getBitmapFromCache>>> get cached bitmap success");
                    bm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight());

                    return bm;
                }
            }finally {
                CloseableReference.closeSafely(imageReference);
            }
        }else {
            // cache miss
            return null;
        }
    }finally {
        dataSource.close();
    }

    return null;
}
 
开发者ID:zjupure,项目名称:SneezeReader,代码行数:45,代码来源:ShareActivity.java


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