aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Need java program to convert WMF file to Graphics2D object and vice-versa Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Need java program to convert WMF file to Graphics2D object and vice-versa" Watch "Need java program to convert WMF file to Graphics2D object and vice-versa" New topic
Author

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

Mansa Kumar
Greenhorn

Joined: Nov 16, 2008
Posts: 6
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
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need java program to convert WMF file to Graphics2D object and vice-versa