@Override protected Bitmap onGetBitmap() { if (mBitmap != null) return mBitmap; BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), mResId, options); mBitmap = bitmap; setSize(bitmap.getWidth(), bitmap.getHeight()); byte[] chunkData = bitmap.getNinePatchChunk(); mChunk = chunkData == null ? null : NinePatchChunk.deserialize(bitmap.getNinePatchChunk()); if (mChunk == null) { throw new RuntimeException("invalid nine-patch image: " + mResId); } return bitmap; }