android.content.res.Resources#openRawResourceFd()源码实例Demo

下面列出了android.content.res.Resources#openRawResourceFd() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: image_jpeg   文件: ImageJpegPlugin.java
public void getImgInfo(Result successResult, Resources res, int resId) {
  HashMap map = new HashMap();
  map.put("resId", resId);
  try {
    if (resId != 0) {
      final BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      AssetFileDescriptor af = res.openRawResourceFd(resId);
      map.put("size", af.getLength());
      af.close();
      InputStream is = res.openRawResource(resId);
      BitmapFactory.decodeStream(is, null, options);
      is.close();
      map.put("width", options.outWidth);
      map.put("height", options.outHeight);
    } else {
      map.put("error", "resources doesn't exist");
    }
    successResult.success(map);
  } catch (Exception e) {
    map.put("error", e.getMessage());
    successResult.success(map);
  }
}
 
源代码2 项目: sketch   文件: GifDrawable.java
/**
 * Creates drawable from resource.
 *
 * @param res Resources to read from
 * @param id  resource id (raw or drawable)
 * @throws NotFoundException    if the given ID does not exist.
 * @throws IOException          when opening failed
 * @throws NullPointerException if res is null
 */
public GifDrawable(@NonNull Resources res, @RawRes @DrawableRes int id) throws NotFoundException, IOException {
	this(res.openRawResourceFd(id));
	final float densityScale = GifViewUtils.getDensityScale(res, id);
	mScaledHeight = (int) (mNativeInfoHandle.getHeight() * densityScale);
	mScaledWidth = (int) (mNativeInfoHandle.getWidth() * densityScale);
}
 
/**
 * Retrieves from resource.
 *
 * @param res Resources to read from
 * @param id  resource id
 * @throws android.content.res.Resources.NotFoundException if the given ID does not exist.
 * @throws java.io.IOException                             when opening failed
 * @throws NullPointerException                            if res is null
 */
public GifAnimationMetaData(@NonNull Resources res, @DrawableRes @RawRes int id) throws Resources.NotFoundException, IOException {
    this(res.openRawResourceFd(id));
}
 
/**
 * Creates drawable from resource.
 *
 * @param res Resources to read from
 * @param id  resource id (raw or drawable)
 * @throws NotFoundException    if the given ID does not exist.
 * @throws IOException          when opening failed
 * @throws NullPointerException if res is null
 */
public GifDrawable(@NonNull Resources res, @DrawableRes @RawRes int id) throws NotFoundException, IOException {
    this(res.openRawResourceFd(id));
}
 
源代码5 项目: Overchan-Android   文件: GifDrawable.java
/**
 * Creates drawable from resource.
 *
 * @param res Resources to read from
 * @param id  resource id
 * @throws NotFoundException    if the given ID does not exist.
 * @throws IOException          when opening failed
 * @throws NullPointerException if res is null
 */
public GifDrawable(Resources res, int id) throws NotFoundException, IOException {
    this(res.openRawResourceFd(id));
}
 
源代码6 项目: sketch   文件: GifAnimationMetaData.java
/**
 * Retrieves from resource.
 *
 * @param res Resources to read from
 * @param id  resource id
 * @throws android.content.res.Resources.NotFoundException if the given ID does not exist.
 * @throws java.io.IOException                             when opening failed
 * @throws NullPointerException                            if res is null
 */
public GifAnimationMetaData(@NonNull Resources res, @RawRes @DrawableRes int id) throws Resources.NotFoundException, IOException {
	this(res.openRawResourceFd(id));
}
 
源代码7 项目: meatspace-android   文件: GifDrawable.java
/**
 * Creates drawable from resource.
 * @param res Resources to read from
 * @param id resource id
 * @throws android.content.res.Resources.NotFoundException if the given ID does not exist.
 * @throws java.io.IOException when opening failed
 * @throws NullPointerException if res is null
 */
public GifDrawable ( Resources res, int id ) throws NotFoundException, IOException
{
	this( res.openRawResourceFd( id ) );
}