Jump to content
Software FX Community

Unexplained problem with Export() to bitmap


User (Legacy)

Recommended Posts

Hi,

(This is the extracted core of the problem

discussed but not explained in another thread

"On Export() to format usable in MS Word". Full

example and results attached -- about 5 KB.)

To demonstrate the problem, I have created the

extremely shortened windows application (C++,

plain Win32, no MFC) that does not create a

visible application window, but only the invisible

window of ChartFX component (Cfx4032.dll, ver.

5.0.14.1) as a child of the desktop window.

The Export() to wmf is produced correctly, while

export to bmp produces a kind of technically

correct but unexpected bitmap (4x4 pixels, 102

bytes, can be loaded into a bitmap editor). Should

this be considered a bug? Can you explain why it

behaves so?

The attached zip file contains also full source of

the testing application with tests for

success/failure of operations... (about 5 KB, one

ImgExport.cpp file, about 100 lines, can be

compiled from command line).

The attached zip file contains also

the batch file compile.bat that calls cl.exe to

obtain the ImgExport.exe.

When running the example, the chart.bmp,

chart.tsv, and chart.wmf are produced in the

working directory. The files--as produced on my

computer--are also included in the zip archive.

Thanks for any help,

Petr

P.S. Not to force you to unzip the archive, the

full source looks this way:

---------------------------------------------

#include <cassert>

#include <stdio.h>

#import "c:\Program Files\Common Files\Software FX Shared\sfxbar.dll"

#import "c:\Program Files\Common Files\Software FX Shared\Cfx4032.dll"

int WINAPI WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTR lpCmdLine,

int nShowCmd)

{

HRESULT hRes = CoInitialize(0);

assert(SUCCEEDED(hRes));

{

// Create the instance of the Chart FX. You need not to put your

// licence string if you run this on the computer where the

development

// version of CFX is installed.

//

ChartfxLib::IChartFXPtr spChartFX;

IClassFactory2 *pFactory2;

LPUNKNOWN pUnk;

HRESULT hr = CoGetClassObject(__uuidof(ChartfxLib::ChartFX),

CLSCTX_INPROC_SERVER,

0,IID_IClassFactory2,

(LPVOID FAR *) &pFactory2);

if (SUCCEEDED(hr))

{

hr = pFactory2->CreateInstanceLic(0, 0, IID_IUnknown,

0, // OLESTR("...licence

string here for non-development instalation..."),

(LPVOID FAR *) &pUnk);

if (SUCCEEDED(hr))

{

spChartFX = pUnk;

pUnk->Release();

pUnk = 0;

}

pFactory2->Release();

pFactory2 = 0;

}

if (FAILED(hr))

{

MessageBox(0, "Error during Chart FX Creation", "",

MB_ICONERROR);

return 0;

}

assert(spChartFX != NULL);

// Now, set demonstration data for the chart.

//

try

{

spChartFX->OpenDataEx(ChartfxLib::COD_VALUES, 2, 3);

int n = 2;

spChartFX->GetSeries()->GetItem(0)->PutYvalue(0, n++ * 100);

spChartFX->GetSeries()->GetItem(0)->PutYvalue(1, n++ * 100);

spChartFX->GetSeries()->GetItem(0)->PutYvalue(2, n++ * 100);

spChartFX->GetSeries()->GetItem(1)->PutYvalue(0, n++ * 100);

spChartFX->GetSeries()->GetItem(1)->PutYvalue(1, n++ * 100);

spChartFX->GetSeries()->GetItem(1)->PutYvalue(2, n++ * 100);

spChartFX->CloseData(ChartfxLib::COD_VALUES);

}

catch (...)

{

MessageBox(0, "Unhandled exception", "", MB_ICONERROR);

}

// Create the invisible window of the Chart FX.

// Dimensions are set to 400x300.

//

const short cChartID = 9999;

hr =

spChartFX->CreateWnd(reinterpret_cast<long>(GetDesktopWindow()),

cChartID, 0, 0, 400, 300, WS_CHILD);

assert(SUCCEEDED(hr));

assert(spChartFX != NULL);

// Test the export (hardwired file names).

//

_unlink("chart.bmp");

_unlink("chart.tsv");

_unlink("chart.wmf");

hr = spChartFX->Export(ChartfxLib::CHART_BITMAP, "chart.bmp");

assert(SUCCEEDED(hr)); // S_OK returned

hr = spChartFX->Export(ChartfxLib::CHART_DATA, "chart.tsv");

assert(SUCCEEDED(hr)); // S_OK returned

hr = spChartFX->Export(ChartfxLib::CHART_METAFILE, "chart.wmf");

assert(SUCCEEDED(hr)); // S_FALSE returned

spChartFX = NULL; // Release()

MessageBox(0, "The End.\n"

"Look for chart.bmp, chart.tsv, and chart.wmf\n"

"in the working directory.",

"Test of the Export()", 0);

}

CoUninitialize();

return 0;

}

---------------------------------------------

--

Petr Prikryl (prikrylp at skil dot cz)

Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...