Jump to content
Software FX Community

Why so big exported METAFILE?


User (Legacy)
 Share

Recommended Posts

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

"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

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

"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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...