Last active
October 8, 2015 01:58
-
-
Save oksep/ec238da7a587b84aef5f to your computer and use it in GitHub Desktop.
Decode a stream to ninePatchDrawable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * input must be create by /bin/crunk | |
| */ | |
| public static Drawable getNinePatchDrawable(Context context, InputStream input) { | |
| Bitmap ninePathBmp = null; | |
| ninePathBmp = BitmapFactory.decodeStream(input); | |
| if (ninePathBmp == null) { | |
| return null; | |
| } | |
| byte[] chunk = ninePathBmp.getNinePatchChunk(); | |
| boolean result = NinePatch.isNinePatchChunk(chunk); | |
| if (result) { | |
| return new NinePatchDrawable(context.getResources(), ninePathBmp, chunk, new Rect(), null); | |
| } | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment