Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Rendering on a transformed G2D object not working with some WMFs

Last post 09-09-2008, 11:13 AM by SteveT@episys.com. 2 replies.
Sort Posts: Previous Next
  •  09-09-2008, 4:15 AM 143087

    Rendering on a transformed G2D object not working with some WMFs

    Attachment: Present (inaccessible)
    Hi there,

    Below is the sample code from our test harness' paint() method. Some of the WMF files that we have do not render in the correct place on the JPanel. I have attached a WMF that exhibits this behaviour

        public void paint(Graphics g) {
                 Graphics2D g2d = (Graphics2D)g;
                 try {
                     FileInputStream file = new FileInputStream("C:\\1080HD.wmf");
                     WmfMetafile efile = new WmfMetafile(file);
                   
                     g2d.translate(30 , 600 );
                     g2d.scale(0.5,0.5);
                     g2d.drawRect(0,0,(int)efile.getWidth(), (int)efile.getHeight());
                      efile.playMetafile(g2d);
                    
                 }catch (Exception ex) {
                     ex.printStackTrace();
                 }
               
            }

    Any thoughts

    Kind Regards

    Mark
     
  •  09-09-2008, 10:51 AM 143159 in reply to 143087

    Re: Rendering on a transformed G2D object not working with some WMFs

    Hello Mark.
    Looks like you're ignoring metafile's starting coordinates. Unlike regular images, metafiles have not only width and height, but x and y too. The metafile, you've attached, have x=268.333 and y=-602, so, it's natural it doesn't fit to {0,0,width,height} rectangle. Please check Matafile.getMinX() and getMinY() functions. CreateDefaultRendering ignores these offset coordinates, other rendering functions aren't.

    Nikolay Kuzmin
    Developer
    Aspose.Slides Team
    http://www.aspose.com
    Your File Format Experts
    Keep in touch! We're on Twitter and Facebook
     
  •  09-09-2008, 11:13 AM 143163 in reply to 143159

    Re: Rendering on a transformed G2D object not working with some WMFs

    Excellent, thanks. That has fixed our issue.
     
View as RSS news feed in XML