Manipulate Metafile colours

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Manipulate Metafile colours

Post by edbored » 05 Oct 2005, 08:40

I have a large amount of .wmf/.emf files where the background is black with white lines (exported from a CNC laser cutter program).

I'd like to set this to grayscale or invert - black lines on a white background prior to printing.

Is there a way of loading metafiles into a TSgDXFImage such that I can then change the background and "pen" colours?

Do you know of any other way I can do this (link is good <g>).

Thanks,
EdB

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 05 Oct 2005, 11:56

Hi,

1. This is possible to implement by our products: DXF Export VCL (http://www.cadsofttools.com/download/DXFExporterSDK.zip) and CAD Import VCL (http://www.cadsofttools.com/download/CADImportVCL.zip). It is necessary to export by DXF Export VCL metafile to DXF and then to manage with it by CAD Import VCL.

2. But there is another way.
It is available to invert colors when drawing metafile (white to black, black to white). Next WIN API function fulfill this task:
BOOL PatBlt(
HDC hdc, // handle to device context
int nXLeft, // x-coord. of upper-left corner of rect. to be filled
int nYLeft, // y-coord. of upper-left corner of rect. to be filled
int nWidth, // width of rectangle to be filled
int nHeight, // height of rectangle to be filled
DWORD dwRop // raster operation code
);

It is necessary to set dwRop = DSTINVERT when calling this function. We have tested this on our demo Viewer (available in CADImportVCL.zip package in CADImportVCL\Delphi\Demos\Viewer folder):

procedure TForm1.sgPaintBoxPaint(Sender: TObject);
// variables
begin
PatBlt(sgPaintBox.Canvas.Handle, 0,0, sgPaintBox.Width, sgPaintBox.Height, DSTINVERT);// sgPaintBox: TsgImage;
// code below

It works!!!

We'd be grateful if you could send to us such wmf/emf file if these explanations couldn't help.

Sergey.

please post questions to the forum or write to support@cadsofttools.com

edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Post by edbored » 05 Oct 2005, 18:24

Thanks Sergey,

I'll add this to the previewer - let the user toggle invert on/off as required.

The application uses ReportBuilder - and loads/prints wmf files without user intervention.

Unfortunately not ALL the emf/wmf files are "black background" - a rather large amount have no background and red, green, or yellow lines instead. I'll try the invert on these sometime this week - as long as the "blank" background remains blank (and doesn't go black) then maybe you've solved it for me!

I have a license for CADImportVCL, maybe it's worth getting DXFExporter to force the equivalent of "dmBlack" on the wmf...

Cheers,
EdB

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 17 Oct 2005, 18:25

Hi,

We'd like to know if this problem is solved for you.

Best regards,
Sergey.

please post questions to the forum or write to support@cadsofttools.com

edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Post by edbored » 03 Nov 2005, 04:13

(Been out of town for about 2 weeks).

Only one client uses metafiles - the others are using DXF/DWG so this isn't an issue.

The metafile user has decided to "wait and see" if the white-lines-on-black drawings "are a problem."

I have the feeling they will get their CAD operators to eliminate the metafiles, and re-export the drawings as DXF instead.

Thanks.

EdB

Post Reply