use of android.content.res.BridgeResources.NinePatchInputStream in project android_frameworks_base by ParanoidAndroid.
the class BitmapFactory_Delegate method nativeDecodeStream.
@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, Rect padding, Options opts, boolean applyScale, float scale) {
Bitmap bm = null;
//TODO support rescaling
Density density = Density.MEDIUM;
if (opts != null) {
density = Density.getEnum(opts.inDensity);
}
try {
if (is instanceof NinePatchInputStream) {
NinePatchInputStream npis = (NinePatchInputStream) is;
npis.disableFakeMarkSupport();
// load the bitmap as a nine patch
com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
false);
// get the bitmap and chunk objects.
bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), true, /*isMutable*/
density);
NinePatchChunk chunk = ninePatch.getChunk();
// put the chunk in the bitmap
bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
// read the padding
int[] paddingarray = chunk.getPadding();
padding.left = paddingarray[0];
padding.top = paddingarray[1];
padding.right = paddingarray[2];
padding.bottom = paddingarray[3];
} else {
// load the bitmap directly.
bm = Bitmap_Delegate.createBitmap(is, true, density);
}
} catch (IOException e) {
Bridge.getLog().error(null, "Failed to load image", e, null);
}
return bm;
}
Aggregations