Java: jak zrobić BufferedImage z grafiki SVG

SVG to przy­jem­ny, otwar­ty for­mat gra­fi­ki wek­to­ro­wej. Aby go wyko­rzy­stać w Javie, potrzeb­na będzie biblio­te­ka Batik. Żeby łatwo uzy­skać Buf­fe­re­dI­ma­ge zamiast zapi­sy­wać wyren­de­ro­wa­ne SVG do pli­ku, sko­rzy­sta­my z kla­sy któ­rej kod znaj­du­je się na jed­nej z list dyskusyjnych.

Powyż­sze roz­wią­za­nie moż­na wygo­oglać, lecz oto moja war­tość doda­na 🙂 Mini­mal­na lista pli­ków .jar z Bati­ka, któ­re trze­ba dodać do pro­jek­tu by SVGRen­de­rer 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 komentarz do “Java: jak zrobić BufferedImage z grafiki SVG

  1. Wiel­kie dzię­ki za tę skró­co­ną listę klas 🙂 Dzię­ki tobie nie musia­łem sam tego przerabiać.

    Zauwa­ży­łem, że poda­ny przez cie­bie przy­kład na dowol­nym SVG uru­cha­mia się rów­nież bez xerces_2_5_0.jar, resz­ta klas jest wymagana

    Pozdra­wiam, UsagiAddict

  2. Być może masz xer­ce­sa już na ścież­ce, w ser­we­rze apli­ka­cyj­nym czy w lib/endorsed w JVM — u mnie trze­ba było dodać.

  3. Dear 4KM and 4KJ,I am exci­ted abo­ut the Olym­pics and can’t wait for them to start. We have Foxtel at home so I will be able to watch any of the evn­tes when I feel like it.I remem­ber the 1984 Olym­pics which were held in Los Ange­les. I was 16 and remem­ber being able to stay up late to watch them as we did­n’t have Foxtel back then.Dean Lukin won a gold medal in the super heavwe­ight cate­go­ry. He was so strong with big musc­les. He rema­ins Austra­lia­’s only olym­pic gold meda­list for weigh­tli­fting. He also car­ried the Austra­lian flag at the clo­sing ceremony.I was luc­ky eno­ugh to rece­ive a gold pen­dant from my Gran­dad that year which was Wil­ly the koala. Wil­ly was the Austra­lian team mascot that year and it was the first time the Austra­lian team had a mascot. Do you know what a mascot is and is the­re one for the Lon­don olympics?I could bring it to your clas­sro­om so you could see it if you would like!My mum went to the 1956 Olym­pics with a scho­ol gro­up. She said it was a won­der­ful experience.Have a gre­at day and not long to wait now for the Olym­pics to start.Bye for now.Sandi (Max’s mum):)

Możliwość komentowania została wyłączona.