Export JPanel to vector graphics

前端 未结 7 1902
梦如初夏
梦如初夏 2020-12-17 04:46

I would like to export the image in my JPanel to a vector graphics file so it can be edited and printed at a higher-than-screen resolution. Essentially I want its pai

7条回答
  •  我在风中等你
    2020-12-17 05:15

    this is basically not possible directly, as the low level java api works in terms of raster (pixels) and is never stored in vector format. (Check the API of java.awt.Graphics to see what I mean).

    there are some general purpose program that convert raster to vector formats, this is one I found on a quick search: http://autotrace.sourceforge.net/index.html

    so, using such a program you can divide your problem into two smaller problems:

    1. convert your JPanel into a bitmap or file (http://www.jguru.com/faq/view.jsp?EID=242020)
    2. run autotrace on the file.

提交回复
热议问题