Here you can find the source of draw9Patch(BufferedImage image, Integer[] patches, float ratio)
private static void draw9Patch(BufferedImage image, Integer[] patches, float ratio)
//package com.java2s; /*// ww w . j ava2s .co m * ****************************************************************************** * * Copyright 2015 See AUTHORS file. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * ***************************************************************************** */ import java.awt.image.BufferedImage; public class Main { private static void draw9Patch(BufferedImage image, Integer[] patches, float ratio) { int width = image.getWidth(); int height = image.getHeight(); int wStart = (int) (patches[0] * ratio) + 1; // this number should be rounded UP int wEnd = (int) (width - patches[1] * ratio) - 1; int hStart = (int) (patches[2] * ratio) + 1; // this number should be rounded UP int hEnd = (int) (height - patches[3] * ratio) - 1; for (int i = wStart; i < wEnd; i++) { image.setRGB(i, 0, 0xFF000000); image.setRGB(i, height - 1, 0xFF000000); } for (int i = hStart; i < hEnd; i++) { image.setRGB(0, i, 0xFF000000); image.setRGB(width - 1, i, 0xFF000000); } } }