Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need java program to convert WMF file to Graphics2D object and vice-versa

 
Mansa Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need a java program to convert a WMF file to Graphics2D object and another program to convert the Graphics2D object back to WMF file. This is because I already have another program (MANIPULATION CODE) which takes in Graphics2D as input and manipulates the data and returns back Graphics2D as output. Sequence is something like this:

WMF -> Graphics2D -> MANIPULATION CODE -> Graphics2D -> WMF

I tried using the below code snippet to convert WMF to Graphics2D but it did not work.
Line 1: InputStream in = new FileInputStream(file);
Line 2: BufferedImage image = ImageIO.read(in);
Line 3: Graphics2D g2 = image.createGraphics();

It gives a null pointer exception on Line 3 because I believe .WMF is not one of the reader formats.

Is there any code which can convert my WMF to Graphics2D and vice-versa.

Thanks a ton in advance
Mansa
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out http://www.java2s.com/Product/Java/Graph-Image-Diagram-Movie/WMF.htm

It lists codes that purport to be able to read and write WMF from Java code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic