This is a migrated thread and some comments may be shown as answers.
Incorrect export to emf
6 Answers 6 Views
This is a migrated thread and some comments may be shown as answers.
Valery
Top achievements
Rank 1
Valery asked on 15 Apr 2020, 04:21 AM

I need to save the chart in emf. I write

         radChartViewAny.ExportToImage(saveFileDialog1.FileName, radChartViewAny.Size, ImageFormat.Emf);

The chart is saved to a file in emf format, but this is only a parody of emf:

1. The file size is very large. It doesn’t happen if it is a normal emf file

2. If you open this file in any program (for example, Word), then there is a "ladder" effect. Those, the file just contains a graph in the form of bitmap, but not the emf commands

 


6 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Apr 2020, 05:08 AM

Hello, Valery,

The ExportToImage method internally uses the following approach for creating the Emf file:

            RadGdiGraphics radGraphics = new RadGdiGraphics(graphics);

            if (imageFormat == ImageFormat.Emf ||
                imageFormat == ImageFormat.Wmf)
            {
                Metafile metafile = new Metafile(stream, graphics.GetHdc()); // file is created here
                using (Graphics g = Graphics.FromImage(metafile))
                {
                    g.DrawImage(bmp, Point.Empty);
                }

                metafile.Dispose();
                graphics.ReleaseHdc();
            }

A similar approach is demonstrated in the following StackOverflow thread: https://stackoverflow.com/questions/5270763/convert-an-image-into-wmf-with-net 

Could you please specify more details about the exact problem that you are facing with the exported Emf file? I have also attached my sample project for your reference together with exact Emf file. Could you please specify the exact steps how to reproduce the problem?

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Valery
Top achievements
Rank 1
answered on 16 Apr 2020, 06:30 AM

Your example file "exprtedChart.emf" has the same problems - it's pseudo-emf, because it contains the chart as a bitmap and not as vectors.

Your problem here is on this line:

g.DrawImage(bmp, Point.Empty);

You draw a bitmap here.

It should be:

 

chart.Draw(g);

I.e. your RadChartView should draw itself on Graphics.

 

See your example on StackOverflow (lines written by Peter Huang). So he does it right, he doesn’t draw a bitmap on Graphics, he uses

 

g.DrawArc(Pens.Black,0,0,200,200,0,360);

0
Valery
Top achievements
Rank 1
answered on 17 Apr 2020, 08:01 AM

I parsed your example file "exportedChart.emf". That's what it contains:

Horizontal-Resolution = 141.7674
Vertical-Resolution   = 141.402

Frame-Width  = 8599.916
Frame-Height = 5747.963

Bounds-Width  = 480pix
Bounds-Height = 320pix

■ 000-EmfHeader: At=0, TotalLength=108Bytes, DataLength=100Bytes
  Bounds: Lft=0, Top=0, Rgt=479, Btm=319
  Frame:  Lft=0, Top=0, Rgt=8582, Btm=5730
  Device:      Wdt=1920, Hgh=1080
  Millimeters: Wdt=344, Hgh=194
  Version: Major=1, Minor=0
◙ 001-EmfGdiComment: At=108, TotalLength=44Bytes, DataLength=36Bytes
► EmfPlusCommentIdentifier: EMF+
● 00 EmfPlusCommentType: EmfPlusHeader
  Size: RecordSize=28, DataSize=16
  Resolution: DpiX=96, DpiY=96
  Meta-data: Signature=DBC01, GraphicsVersion=GraphicsVersion1_1
◙ 002-EmfGdiComment: At=152, TotalLength=7296Bytes, DataLength=7288Bytes
► EmfPlusCommentIdentifier: EMF+
● 00 EmfPlusCommentType: EmfPlusObject
  Size: RecordSize=7228, DataSize=7216
  Identity: Continued=False, ObjectID=0
- PlusObjectType: ObjectTypeImage/not serialized
  UNKNOWN EmfPlusObjectType
● 01 EmfPlusCommentType: EmfPlusDrawImagePoints
■ 003-EmfSaveDC: At=7448, TotalLength=8Bytes, DataLength=0Bytes
■ 004-[EmfSetIcmMode]: At=7456, TotalLength=12Bytes, DataLength=4Bytes
■ 005-[00000015/15]: At=7468, TotalLength=12Bytes, DataLength=4Bytes
■ 006-[00000015/15]: At=7480, TotalLength=12Bytes, DataLength=4Bytes
■ 007-[00000051/51]: At=7492, TotalLength=153964Bytes, DataLength=153956Bytes
■ 008-[EmfBitBlt]: At=161456, TotalLength=100Bytes, DataLength=92Bytes
■ 009-EmfRestoreDC: At=161556, TotalLength=12Bytes, DataLength=4Bytes
  DC: most recently saved
◙ 010-EmfGdiComment: At=161568, TotalLength=28Bytes, DataLength=20Bytes
► EmfPlusCommentIdentifier: EMF+
● 00 EmfPlusCommentType: EmfPlusEndOfFile
  Size: RecordSize=12, DataSize=0
■ 011-EmfEof: At=161596, TotalLength=20Bytes, DataLength=12Bytes
  PalEntries: 0

 

This is actually one bitmap. Tell your programmers that they are not creating emf files correctly

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Apr 2020, 12:50 PM

Hello, Valery,

Thank you for the provided information.

Currently, RadChartView doesn't support exporting to a vector image. Indeed, the current rendering mechanism allows exporting to a bitmap according to one of the provided ImageFormats.

I have logged a feature request in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item. I would like to note that this functionality would require changes in the renderer that is used in RadChartView. Hence, it needs planning according to the demand by other customers that we have.

I have also updated your Telerik points.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Valery
Top achievements
Rank 1
answered on 21 Apr 2020, 03:41 AM

You write "the current rendering mechanism allows exporting to a bitmap according to one of the provided ImageFormats". 

And what is written on the page to which you link: "The properties of the ImageFormat class indicate image formats such as bitmap (Bmp), enhanced metafile (Emf), and icon (Icon). For example, you can use the properties of the ImageFormat class to specify an image format when saving an image using the Save method. You can compare two image formats by using the Equals method."

That is, it clearly says that ImageFormat includes emf. I did not ask you to export to a vector format like svg. You just need to correctly export to the standard emf format. And do not write to me that it is very difficult and "would require changes in the renderer that is used in RadChartView".

I looked at your source.You don’t need to change anything in the rendering. All that needs to be fixed when exporting to emf: do not create an intermediate bitmap and render immediately on graphics of metafile (this.Area.Renderer.Draw(graphics);).

Why do you have this problem marked as "Unplanned"?

Your programmers made a gross mistake, so be so kind as to fix it immediately. By the way, you have the same problem with printing RadChartView

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Apr 2020, 01:09 PM
Hello, Valery,

Thank you for the provided feedback. We take it very seriously and I have escalated this case to our developers.

As the status of the previously referred feedback states (In development), we will improve the export to image functionality for the ImageFormat.Emf. I have also updated the header text of the item. Please make sure that you click the Follow button in order to get notified once the status changes. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Valery
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Valery
Top achievements
Rank 1
Share this question
or