c# and emf metafile strange behavior

Results 1 to 2 of 2

Thread: c# and emf metafile strange behavior

  1. #1
    Join Date
    Dec 1969

    Default c# and emf metafile strange behavior

    hi there<BR><BR>i have a problem with c# and an emf metafile. i hope you guys can help me because this is the second day of hard work and <BR><BR>searching all around the net and i&#039;m on the edge. i&#039;m pulling my hair out of my head. so, here&#039; my problem:<BR><BR>1). I have a code:<BR><BR>...<BR>private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<BR> {<BR> Metafile Butterfly = new Metafile("c:\butterfly.emf");<BR> Bitmap crop = new Bitmap (800, 600);<BR> Graphics gr = Graphics.FromImage(crop);<BR> gr.DrawImage(Butterfly, new Rectangle (0,0,800,600), new Rectangle (100,200,800,600), <BR><BR>GraphicsUnit.Pixel);<BR> gr.Dispose();<BR> crop.Save("c:\1.jpg",ImageFormat.Jpeg);<BR><BR> e.Graphics.DrawImage(Butterfly, 0, 0, 500, 500);<BR> }<BR>...<BR><BR>A code which open my butterfly.emf file, crop it and export the crop. After export the application displays the emf on the <BR><BR>form and displays it corectly. ok. the problem is that the jpeg file is totally black like there was no rendering of emf <BR><BR>inside it before exporting or something like this.<BR><BR>2). the butterfly.emf is exported from illustrator cs. if i work with a corel exported emf file, everything is working ok. <BR><BR>the BIG problem is that none of the corel versions (not even corel draw 12) can export the emf correctly. the only <BR><BR>application from which i can export the emf correctly is illustrator.<BR><BR>3). my exported jpeg is black (nothing in it) which at first i thought that my application doesn&#039;t render the exported emf <BR><BR>but i was wrong because after the export the emf is displayed on my form correctly. sorry for the repetition.<BR><BR>4). any ideas of what in the world is happening? please help me.

  2. #2
    Join Date
    Feb 2009


    Hi, I had exactly the same problem and exactly the same code and I was just about to go nuts because of it when I realized the EMF file had only black pixel data and the destination Image (the jpg one) had as default background the black color. So it was drawing black on black . I've did a gr.FillRectangle(Brushes.White, 0, 0, 100, 100) and everything was visible after .
    I just create an account here to post this for you're problem and I hope is the same situation on your side too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts