private void handleNinePatchDrawable(int resId, NinePatchDrawable drawable, ResourceResponse outResponse) { ResourceResponse[] images = new ResourceResponse[4]; outResponse.Data = images; outResponse.DataType = ARRAY; int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); int[] sizes = {w, h, Math.max(MIN_9PATCH_SIZE, Math.min(INC_9PATCH_CONST * w, MAX_9PATCH_SIZE)), h, w, Math.max(MIN_9PATCH_SIZE, Math.min(INC_9PATCH_CONST * h, MAX_9PATCH_SIZE)), Math.max(MIN_9PATCH_SIZE, Math.min(INC_9PATCH_CONST * w, MAX_9PATCH_SIZE)), Math.max(MIN_9PATCH_SIZE, Math.min(INC_9PATCH_CONST * h, MAX_9PATCH_SIZE))}; for (int i = 0; i < images.length; i++) { int tw = sizes[i * 2]; int th = sizes[(i * 2) + 1]; ResourceResponse rr = new ResourceResponse(); images[i] = rr; rr.id = resId; rr.DataType = BASE64_PNG; rr.Context = String.format("Size: %sx%s %s", tw, th, i == 0 ? "original" : ""); rr.Data = Base64.encodeToString(drawDrawableWithSize(drawable, tw, th, mClearPaint), Base64.NO_WRAP); } }