MetaFile loosing linestyle
MetaFile loosing linestyle
Hi, i just want to know if you are planning on redoing the DrawToMetaFile function to avoid the Delphi bug where LineStyle are behing ignored in a metafile. If my graph got some psDot, i will lose that style once exported to a metafile. (Append only when you resize the metafile about 1.5x the original size). I did some test and if i simulate the style of a pen (MoveTo,LineTo for a Dot line), it work #1 in a metafile. Hope i was clear enought for you to understand me hehehehhe
Thanks again
Thanks again
Re: MetaFile loosing linestyle
Hi GoToXY,
I've found that the line series style isn't drawn correctly when having the pen wider and saving the chart to windows metafile (wmf). But the exportation works fine exporting to enhanced metafile (emf). Is that what you are reproducing? Here is the code I used:
I've found that the line series style isn't drawn correctly when having the pen wider and saving the chart to windows metafile (wmf). But the exportation works fine exporting to enhanced metafile (emf). Is that what you are reproducing? Here is the code I used:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Chart1.Legend.Visible := false;
Chart1.AddSeries(TLineSeries.Create(self));
Chart1[0].FillSampleValues(25);
Chart1[0].Pen.Style := psDash;
Chart1.SaveToMetafile('C:\tmp\test1.wmf'); //correct
Chart1.SaveToMetafileEnh('C:\tmp\test1.emf'); //correct
Chart1[0].Pen.Width := 2;
Chart1.SaveToMetafile('C:\tmp\test2.wmf'); //incorrect
Chart1.SaveToMetafileEnh('C:\tmp\test2.emf'); //correct
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
I need it in memory, so i use a TMetaFile and a TMetaFileCanvas, i do Chart.drawToMetaFile then TheMetaFile.SaveToStream. I always had that problem with delphi (with my other software) so i touhg you could have already done some function to simulate the drawing to make emf keep track of linestile with 1 width.
Re: MetaFile loosing linestyle
I checked it doing SaveToFile and thats true: EMF = Good, WMF = 2x bigger and not good. So if i would savethem to disk it would have been perfect but since i need to use it in memory the only way i know is SaveToStream but that function doesnt allow me to save it in EMF Format.
Any Idea ?
Any Idea ?
Re: MetaFile loosing linestyle
oh well, i did other test and it seems Delphi cant print EMF correctly anyway And TImage dont display it correctly too. Looks like im screw lol
Re: MetaFile loosing linestyle
Hi GoToXY,
Excuse us for the delay. Please take a look at this example of how you could create a metafile from a chart. Note that I draw it to a TImage component to see if the pen is stored fine:
Excuse us for the delay. Please take a look at this example of how you could create a metafile from a chart. Note that I draw it to a TImage component to see if the pen is stored fine:
Code: Select all
uses series;
procedure TForm1.FormCreate(Sender: TObject);
var tmpMeta: TMetafile;
begin
Chart1.View3D := false;
Chart1.Legend.Visible := false;
Chart1.AddSeries(TLineSeries.Create(self));
Chart1[0].FillSampleValues(25);
Chart1[0].Pen.Style := psDash;
Chart1[0].Pen.Width := 2;
tmpMeta := Chart1.TeeCreateMetafile(False,Chart1.ClientRect);
try
Image1.Canvas.StretchDraw(Rect(0,0,Image1.Width, Image1.Height),tmpMeta);
finally
tmpMeta.Free;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
Hi Yeray,
For the series, everything is fine, but not for the grid. The Axis (Left and Bottom) grids became lines on printing resizing.
BTW: Thx for letting me know about that function, that will save me lots of lines in my softwares
For the series, everything is fine, but not for the grid. The Axis (Left and Bottom) grids became lines on printing resizing.
BTW: Thx for letting me know about that function, that will save me lots of lines in my softwares
After changing False to True (because i needed Enhance MF) saving is good and every line that have a style are displayed with that style with Windows picture viewer. But when it comes to view it in Delphi, Grids line are still in solid style. I did other test and it seem to happend only when the width of the line = 1. So i presume that you used a custom DrawLine when width are greater than 1, but should be anytime to solve Delphi bug being unabled to display MEtaFile correctly. I wish im correct and it can be solve.tmpMeta := Chart1.TeeCreateMetafile(False,Chart1.ClientRect);
Re: MetaFile loosing linestyle
Hi GoToXY,
Could you please send us a simple example project or a complete (but simple) code snipped we can run as-is here to reproduce it?
Thanks in advance.
Could you please send us a simple example project or a complete (but simple) code snipped we can run as-is here to reproduce it?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
Hi, ive attached a Simple Application that reproduce the bug with 3 ScreenShot taken from my computer. Hope we can do something about it
Thanks a lot and have a good day.
Thanks a lot and have a good day.
- Attachments
-
- MetaFileChart.zip
- MetaFileBug
- (116.8 KiB) Downloaded 752 times
Re: MetaFile loosing linestyle
Hi GoToXY,
Ah, excuse me, the mistake was on my suggestion. This line is creating a metafile in the same size of the chart and can present problems if you want to resize it:
So I recommend you to create that metafile in the final size so that the chart will be redrawn internally to that size and the image will look better:
Ah, excuse me, the mistake was on my suggestion. This line is creating a metafile in the same size of the chart and can present problems if you want to resize it:
Code: Select all
tmpMeta := Chart1.TeeCreateMetafile(False,Chart1.ClientRect);
Code: Select all
tmpMeta := Chart1.TeeCreateMetafile(True,Rect(0,0,Image1.Width,Image1.Height));
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
Hi Yeray,
I dont really understand what you are suggesting me. I am using MetaFile because metafile are Vectors It should look very nearly the same on any size. Why i am using MetaFile is for an easy way to Show / Print and store the Chart so i can use it in several other application. I didnt went through all your line of code, but im pretty sure this bug happend because the width of the line is equal to 1 and im pretty sure, you dont use a custom draw to simulation a linestyle when its equal to 1 because delphi should manage it already by himself. But in fact, Delphi dont really managed it by himself because when you resize a metafile with linestyle and width = 1 using regular API ported in delphi, you will lose all linestyle when you resize it bigger than the original. I havent tried it on a C# or C++ application, but im pretty sure it should work fine.
I dont really understand what you are suggesting me. I am using MetaFile because metafile are Vectors It should look very nearly the same on any size. Why i am using MetaFile is for an easy way to Show / Print and store the Chart so i can use it in several other application. I didnt went through all your line of code, but im pretty sure this bug happend because the width of the line is equal to 1 and im pretty sure, you dont use a custom draw to simulation a linestyle when its equal to 1 because delphi should manage it already by himself. But in fact, Delphi dont really managed it by himself because when you resize a metafile with linestyle and width = 1 using regular API ported in delphi, you will lose all linestyle when you resize it bigger than the original. I havent tried it on a C# or C++ application, but im pretty sure it should work fine.
Re: MetaFile loosing linestyle
Hi GoToXY,
Maybe you should consider using tee files to port your charts from an application to another.GoToXY wrote:Why i am using MetaFile is for an easy way to Show / Print and store the Chart so i can use it in several other application
Yes, I guess there could be a problem in delphi's canvas and we can't do too much here. But, if you could send us an example showing that we'll be glad to take a look at it.GoToXY wrote:But in fact, Delphi dont really managed it by himself because when you resize a metafile with linestyle and width = 1 using regular API ported in delphi, you will lose all linestyle when you resize it bigger than the original
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
i already sent a simple application attached to one of my message. If you need it by mail, can you tell me which email to send it to.
Thanks
Thanks
Re: MetaFile loosing linestyle
Hi GoToXY,
I understood that you could reproduce the problem without using teechart: "using regular API ported in delphi". And the application you sent on 14th Oct you are using TeeChart, isn't it?
I understood that you could reproduce the problem without using teechart: "using regular API ported in delphi". And the application you sent on 14th Oct you are using TeeChart, isn't it?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: MetaFile loosing linestyle
Yes, i am using it. But i wonder why you ask that question because there is no LineTo in the source ive sent you. Did you check the simple application i sent you ? Dont take it the wrong way, but you should have known that answer just by looking at my source code.