Java: jak zrobić BufferedImage z grafiki SVG

SVG to przyjemny, otwarty format grafiki wektorowej. Aby go wykorzystać w Javie, potrzebna będzie biblioteka Batik. Żeby łatwo uzyskać BufferedImage zamiast zapisywać wyrenderowane SVG do pliku, skorzystamy z klasy której kod znajduje się na jednej z list dyskusyjnych.

Powyższe rozwiązanie można wygooglać, lecz oto moja wartość dodana 🙂 Minimalna lista plików .jar z Batika, które trzeba dodać do projektu by SVGRenderer działał prawidłowo:

  • batik-anim.jar
  • batik-awt-util.jar
  • batik-bridge.jar
  • batik-css.jar
  • batik-dom.jar
  • batik-ext.jar
  • batik-gvt.jar
  • batik-parser.jar
  • batik-rasterizer.jar
  • batik-script.jar
  • batik-svg-dom.jar
  • batik-transcoder.jar
  • batik-util.jar
  • batik-xml.jar
  • batik.jar
  • xerces_2_5_0.jar
  • xml-apis-ext.jar

3 myśli nt. „Java: jak zrobić BufferedImage z grafiki SVG

  1. Wielkie dzięki za tę skróconą listę klas 🙂 Dzięki tobie nie musiałem sam tego przerabiać.

    Zauważyłem, że podany przez ciebie przykład na dowolnym SVG uruchamia się również bez xerces_2_5_0.jar, reszta klas jest wymagana

    Pozdrawiam, UsagiAddict

  2. Być może masz xercesa już na ścieżce, w serwerze aplikacyjnym czy w lib/endorsed w JVM – u mnie trzeba było dodać.

  3. Dear 4KM and 4KJ,I am excited about the Olympics and can’t wait for them to start. We have Foxtel at home so I will be able to watch any of the evntes when I feel like it.I remember the 1984 Olympics which were held in Los Angeles. I was 16 and remember being able to stay up late to watch them as we didn’t have Foxtel back then.Dean Lukin won a gold medal in the super heavweight category. He was so strong with big muscles. He remains Australia’s only olympic gold medalist for weightlifting. He also carried the Australian flag at the closing ceremony.I was lucky enough to receive a gold pendant from my Grandad that year which was Willy the koala. Willy was the Australian team mascot that year and it was the first time the Australian team had a mascot. Do you know what a mascot is and is there one for the London olympics?I could bring it to your classroom so you could see it if you would like!My mum went to the 1956 Olympics with a school group. She said it was a wonderful experience.Have a great day and not long to wait now for the Olympics to start.Bye for now.Sandi (Max’s mum):)

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *