How can I edit a jpg image through Java?

后端 未结 5 1426
名媛妹妹
名媛妹妹 2021-02-07 10:52

I have loaded a jpg image in which I want to draw letters and circles, given a x,y coordinate.

I have been trying to figure out the paintIcon of the ImageIcon class

<
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 11:34

    The pure-Java way is to use ImageIO to load the image as a BufferedImage. Then you can call createGraphics() to get a Graphics2D object; you can then draw whatever you want onto the image.

    You can use an ImageIcon embedded in a JLabel to do the displaying, and you can add a MouseListener and/or a MouseMotionListener to the JLabel if you're trying to allow the user to edit the image.

提交回复
热议问题