Easy Way To Draw Line On Image in JAVA

In this article you will learn how to draw line on an image in JAVA language. This is very easy way. You also can store this image in your System.

BufferedImage img = new BufferedImage(600, 315, BufferedImage.TYPE_INT_RGB );
//draw line verticle
for(int vl = 0; vl < 315; vl++)
{
     img.setRGB(300, vl, Color.WHITE.getRGB() );
}
       
//draw line horizontal
for(int vh = 0; vh < 600; vh++)
{
    img.setRGB(vh, 157, Color.WHITE.getRGB() );
}
String path = System.getProperty("user.home");
ImageIO.write(img, "PNG", new File(path+"\\Documents\\NetBeansProjects\\img.png"));
Easy Way To Draw Line On Image in JAVA Easy Way To Draw Line On Image in JAVA Reviewed by Unknown on 15:15 Rating: 5