User (Legacy) Posted January 17, 2005 Report Share Posted January 17, 2005 Hi, We are using Cfx4032.dll (5.0.14.1) for displaying charts in our application (C++ VC 7.1, ATL/WTL). Now, the time has come to export the pictures in WMF (Windows Metafile) format to be inserted into the generated MS Word document. The export works fine with one exception. The spike project exports WMF files of size up to 10 kB, which is fine and expected. For some uncovered reason, the similar code in the target application exports images of the size about 900 kB, which is unexpected. The images can be inserted to a Word document. They are displayed correctly, but their size is too big. It seems as if for some reason the images are in some raster form. Because of how the ChartFX component is used in the target application, it seems easier to ask first what should we focus on when searching for the differencies between the spike project and the target application. Do you have any experience with such behaviour? Thanks, Petr -- Petr Prikryl (prikrylp at skil dot cz) Link to comment Share on other sites More sharing options...
Software FX Posted January 17, 2005 Report Share Posted January 17, 2005 How are you exporting these pictures ? Are you using the API or are you using the provided toolbar and menus ? If you are using the API please include the code used to Copy the chart to the clipboard. -- FP Software FX Link to comment Share on other sites More sharing options...
User (Legacy) Posted January 18, 2005 Author Report Share Posted January 18, 2005 "SoftwareFX Support", FP wrote... > How are you exporting these pictures ? Are you using the API or are you > using the provided toolbar and menus ? > If you are using the API please include the code used to Copy the chart to > the clipboard. I am using API. Both spike project and the final application uses the same form of export, like this (checking removed): RECT rc ... // dimensions of the image that use 0.01 mm // logical unit // The hiden window of the chart is resized to force real // dimensions for the MS Word. // WTL::CWindowDC dc(m_hWnd); int LX = dc.GetDeviceCaps(LOGPIXELSX); int LY = dc.GetDeviceCaps(LOGPIXELSY); // Logical units to pixels. // int width = MulDiv(rc.right - rc.left, LX, 2540); int height = MulDiv(rc.bottom - rc.top, LY, 2540); RECT rc2; SetRect(&rc2, 0, 0, width, height); // The window is the one of the chart, and // it is made not to be visible. // ATLASSERT( ! IsWindowVisible()); MoveWindow(&rc2, FALSE); // Update the chart size and export. // m_spChartFX->UpdateSizeNow(); m_spChartFX->Export(ChartfxLib::CHART_METAFILE, fname.c_str()); Then the temporary file is inserted into the Word document. (Would you recommend using clipboard instead of the temporary file?) As the resulting Word document + exported images have only about 20 kB when zipped, I dare to attach the archive. The Word document stores the image inside. The tmpimg1.wmf is only a temporary file that is removed after creating the Word document -- it is big but can be compressed to about 10 kB. The chart.wmf is the result exported by the spike application -- much smaller than the tmpimg1.wmf. The problem is that the final application sets many chart properties elsewhere in the code. Apparently, some settings make the difference in the size of the exported wmf. Any idea? Thanks, Petr -- Petr Prikryl (prikrylp at skil dot cz) Link to comment Share on other sites More sharing options...
Software FX Posted January 19, 2005 Report Share Posted January 19, 2005 Can you attach that "big" metafile ? I may be able to tell why it is so big. -- FP Software FX Link to comment Share on other sites More sharing options...
User (Legacy) Posted January 20, 2005 Author Report Share Posted January 20, 2005 "SoftwareFX Support", FP wrote... > Can you attach that "big" metafile ? I may be able to tell why it is so big. It was attached in my previous message. Anyway, here it is (zipped). Thanks, Petr Link to comment Share on other sites More sharing options...
Software FX Posted January 20, 2005 Report Share Posted January 20, 2005 Sorry about that. Indeed this metafile is just a bitmap. I don't see how the code you have: m_spChartFX->Export(ChartfxLib::CHART_METAFILE, fname.c_str()); could produce such image. Are you exporting the chart as a bitmap somewhere else in your program ? If this is indeed our bug (I don't believe it is, I looked at the code and I see no way that we export a bitmap inside a metafile) we are going to need a repro case, that is a program that reproduces the problem, a program we can run here (with source code) and produces this metafile. I realize this may be difficult for you to isolate but it would be impossible for us to determine what's going on without such repro case. -- FP Software FX Link to comment Share on other sites More sharing options...
User (Legacy) Posted January 21, 2005 Author Report Share Posted January 21, 2005 "SoftwareFX Support", FP wrote... > Indeed this metafile is just a bitmap. I don't see how the code you have: > m_spChartFX->Export(ChartfxLib::CHART_METAFILE, fname.c_str()); > could produce such image. > > Are you exporting the chart as a bitmap somewhere else in your program ? No. This is the only place in my code where the images from chart are exported. > If this is indeed our bug (I don't believe it is, I looked at the code and I > see no way that we export a bitmap inside a metafile) we are going to need a > repro case, that is a program that reproduces the problem, a program we can > run here (with source code) and produces this metafile. I realize this may > be difficult for you to isolate but it would be impossible for us to > determine what's going on without such repro case. I am just refactoring the code to put the CFX related thing closer each other. I will try to isolate the problem. I hope the behaviour does not disappear somehow magically. Then, I will send you the code. Thanks for the effort, Petr -- Petr Prikryl (prikrylp at skil dot cz) Link to comment Share on other sites More sharing options...
User (Legacy) Posted January 24, 2005 Author Report Share Posted January 24, 2005 Hi, It seems that I have found the reason! "Petr Prikryl" <prikrylp at skil dot cz> wrote...> "SoftwareFX Support", FP wrote... > > Indeed this metafile is just a bitmap. I don't see how the code you have: > > m_spChartFX->Export(ChartfxLib::CHART_METAFILE, fname.c_str()); > > could produce such image. > > [...] I realize this may > > be difficult for you to isolate but it would be impossible for us to > > determine what's going on without such repro case. See the attached full example that demonstrates the problem. The big wmf (the raster image) is exported when the CTE_SMOOTH bit of the TypeEx property is switched on. Now I remember, that I had to switch this option off also when calling Paint() method, because the result was somehow strange (copied part of the screen to the result). The remaining question is whether CTE_SMOOTH should be switched off automatically (internally) when doing Export() (and/or Paint()). In other words, is it a bug or feature? Regards, Petr -- Petr Prikryl (prikrylp at skil dot cz) Link to comment Share on other sites More sharing options...
Software FX Posted January 24, 2005 Report Share Posted January 24, 2005 Of course ! (easy to say now that you did all the work) I forgot about CTE_SMOOTH. CTE_SMOOTH paint the chart into a bitmap and then paints the bitmap into the final DC, in this case the metafile. I was a little thrown off by the fact that you said that the problem only occurred in certain computers and not in others so I was looking for some kind of overflow bug or something like that, I did not look into the high level paint logic when CTE_SMOOTH is implemented. Anyways, this is by design. Simply turn of CTE_SMOOTH to get a true vector graph. Sorry about all the confusion. -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.