Delphi syntax to overlay two emf files

Please discuss general Delphi programming topics here.

Delphi syntax to overlay two emf files

Postby norbert » May 15th, 2006, 5:15 pm

Perhaps somebody of You is able to give me a hint how to arrange a transparent EMF image on top of another transparent EMF image.

I tried making the image transparent, making the emf transparent, all useless. Until now, the contents of the background image remain always unvisible.

The EMF structure of both images must not be lost because the print outs should be of high precision. (cutting plotter)
I don't need a complete code but only an idea how to manage EMF transparency with Delphi.
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby Kambiz » May 16th, 2006, 12:31 am

A metafile is natively transparent. Therefore the background of a non-transparent metafile is filled by the metafile creator.

To give back transparency to a non-transparent metafile, you have to go through metafile records, and remove/modify records which fill the background.

If you post a pair of background/foreground metafiles here, I'll reply with a sample code.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm

Postby norbert » May 16th, 2006, 9:14 am

Kambiz,
Let's place a Delphi image control into a scroll box and add a meta file to it.
Now add a second transparent image control over the first one into the same scroll box. Don't add a metafile to the second image control. The meta content of the first placed image is no more visible. To show it You must move the overlaying image control aside.
It's clear that EMF structures are transparent by design except from filled areas. But this is - for me - not a problem of the metafiles themselves but a problem of the image object, which cannnot be made transparent.

I just tried it out again:
(I'm always using a transparent emf structure.)
I place a scroll box, then two image controls and fill both with the same EMF drawing. Nothing appeared on screen. I have to activate/deactivate the image controlls several times until EMF contents are shown. (Once, just after load, it even happened that an image content was shown immediately.) Refresh seems not to function correctly (XP prof).
It's not necessary to edit records.

As soon as both drawings are made visible they can be transperently overlayed to each other as whished. When I drag an image control containing an unvisible emf over the other image control with a visible emf then the dragged image control is not transparent and has the backcolor of the scroll box.
That's what irritates me with Delphi. It reminds me on similiar difficulties with VB6 in the past, however.

Well, I'm using here two new 21" NEC flat screen monitors with a Matrox G550 controller. The behavior is definitely different on the screens. The primary screen gives results as described above, but the secondary one never shows image contents. (with Delphi IDE)

Programmatically, I had no success with it until now (with Delphi syntax).

It seems in fact to be a driver problem or a problem with Delphi itself. It's certainly not the old 'Visible' problem. But when you are conditioned from the past that way your first thought reminds you on your experiences.

Norbert
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby Kambiz » May 16th, 2006, 1:56 pm

Norbert,

I tried to generate the issue using the first case you described. But seems everithing is fine. I checked it out with Delphi 6.

Which version of Delphi do you use?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm

Postby norbert » May 16th, 2006, 10:17 pm

Kambiz,

In the mean time, I tried it on my other Computers, too, which don't use dual screen mode. Everything runs well.

There are two different dual screen modes possible. In the first one, screens are configurable independently from each other, in the second one the Desktop screen of the primary monitor has the same configuration as the secondary monitor ans is an enlargement of the primary one. I'm using the latter configuration.

I tried it out an old screen grabber I wrote eight years ago with VB5/6. It shows similiar difficulties when it grabs the content of a user defined area from Desktop, but in fact shows nothing in it's preview window, whenever grabbing was done on the secondary monitor. The primary one, however, is delivers correct snapshots!

The cause is either one of the XP updates or the Matrox driver. On the other hand, Delphi and VB6 have the same form oriented philosophy. May be that both are out of date in some way. - I'm using Delphi 7. - Be shure, I'll find the bug.

Norbert
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby norbert » May 16th, 2006, 10:36 pm

Kambiz,

You are very kind!!

You wrote: "If you post a pair of background/foreground metafiles here, I'll reply with a sample code."

Perhaps Your code helps as a comparison.

Attached You find two EMFs, one showing a frame, the other one the drawing.


Thanks,

Norbert
Attachments
Test.zip
(36.66 KiB) Downloaded 120 times
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby Kambiz » May 17th, 2006, 11:08 pm

Hi Norbert,

Your EMF files are fine with a single monitor system.

Unfortunately I don't have the second monitor to investigate the issue on a dual monitor system. :(
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm

Postby norbert » May 18th, 2006, 9:58 am

Kambiz,

I found the mysterious bug!
It simply comes from the fact, that a standard query of the screen X/Y size with a single screen pixel resolution of 1920 * 1034 always gives back a result in twips from the screen driver, which overflows the Windows API maximum of 32768 when the total screen size in pixel is added to 3840 x 1034 in pixel, but is internally corrected somehow by the driver which seems simply to clip everything greater that the limits.
I never was confronted with this problem before, even though I always programmed cad with two screens. But in former times there was only one high resolution screen and additionally a text screen, both separated from each other with different ports and memory.
Before I bought the new high resolution flat screens, my eyes were much better and my budjet was lower. So detected software bugs sometimes have a deeper cause....;-)

Norbert
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby Kambiz » May 18th, 2006, 11:05 am

I'm very glad you could find the reason of the bug.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron