Java - Create a shape from border around image

前端 未结 1 696
感情败类
感情败类 2021-01-20 16:55

i have a class that draws a shape from a png image, so that i can use the shape to draw the border of custom buttons that i need for my project. here\'s the code for the cla

1条回答
  •  没有蜡笔的小新
    2021-01-20 17:34

    For tips, look at Smoothing a jagged path. The algorithm to obtain the (crude) outline was relatively quick in the final versions. Creating a GeneralPath is astonishingly faster than appending Area objects.

    The important part is this method:

    public Area getOutline(Color target, BufferedImage bi) {
        // construct the GeneralPath
        GeneralPath gp = new GeneralPath();
    
        boolean cont = false;
        int targetRGB = target.getRGB();
        for (int xx=0; xx

    0 讨论(0)
提交回复
热议问题