Java Code Examples for android.content.res.Resources#openRawResourceFd()
The following examples show how to use
android.content.res.Resources#openRawResourceFd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageJpegPlugin.java From image_jpeg with MIT License | 6 votes |
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); } }
Example 2
Source File: GifDrawable.java From sketch with Apache License 2.0 | 3 votes |
/** * 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); }
Example 3
Source File: GifAnimationMetaData.java From android-gif-drawable-eclipse-sample with MIT License | 2 votes |
/** * 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)); }
Example 4
Source File: GifDrawable.java From android-gif-drawable-eclipse-sample with MIT License | 2 votes |
/** * 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)); }
Example 5
Source File: GifDrawable.java From Overchan-Android with GNU General Public License v3.0 | 2 votes |
/** * 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)); }
Example 6
Source File: GifAnimationMetaData.java From sketch with Apache License 2.0 | 2 votes |
/** * 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)); }
Example 7
Source File: GifDrawable.java From meatspace-android with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * 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 ) ); }