Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

remove the background from EMF

Posted on 2002-05-08
4
Medium Priority
?
506 Views
Last Modified: 2010-04-04
I have a metafile that has been captured from a TRichEdit. As the Rich edit has a white background, so does the metafile. I need to remove this background from the metafile to make it transparent.

The only way I can see to do this is by using EnumEnhMetaFile, and removing the entries that setbkcolor but I can't work out how to do this.

Can anyone tell me how to do this or suggest another way of making the metafile transparent.

Cheers in advance
0
Comment
Question by:mike_tipping
4 Comments
 
LVL 4

Expert Comment

by:nestorua
ID: 6997062
HI,
As if the Help says:
"Description
Transparent specifies whether that the metafile be drawn transparently. TMetafile overrides the write method of the Transparent property to essentially make the property read-only, so setting the property for this object does not change their behavior,"
yuo can't change its Transparent property to True when it is False (if it is True you have no problem).
So, I propose the following:
1.Create new Metafile with Create method.
(in this case newly created Metafile has its Transparent=True)2.Assign to created Metafile that copied from the Richedit.
(It seems the transparent property isn't assigning)
Sincerely,
Nestorua.
0
 

Author Comment

by:mike_tipping
ID: 6998431
I think this bit of the help is meaning that the transparent property makes no difference to the background of the tmetafile. A metafile is a collection of GDI calls that play onto the display canvas so a 'transparent' metafile is actualy onw with no background. Looking at the GDI help there are 2 GDI calls that appear in my metafile setbkcolor and setbkmode and I beleive these are what I need to get rid of or change.

I may be wrong but that's my thinking
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 800 total points
ID: 7002367
hello mike_tipping, As you have found out, the TMetaFile transparent property does not do anything. I had the opossite problem, the metafiles were transparent and I did not want that. Since the drawing operations for a metafile are in an array of records, if those drawing operations draw a background, then it may be difficult to stop it. What I would do id copy it to a Bitmap and Transparent the bitmap.


procedure TForm1.sbut_LoadWmfClick(Sender: TObject);
var
Wmf1: TMetaFile;
TempBmp: TBitmap;
begin
Wmf1 := TMetafile.Create;
Wmf1.LoadFromFile('C:\Temp\Wmf1.wmf');
TempBmp := TBitmap.Create;
TempBmp.Height := Wmf1.Height;
TempBmp.Width := Wmf1.Width;
TempBmp.Canvas.Draw(0,0,Wmf1);
TempBmp.Transparent := True;
//TempBmp.TransparentColor := clWhite;
PaintBox8.Canvas.Draw(0,0,TempBmp);
FreeAndNil(Wmf1);
FreeAndNil(TempBmp);
end;


Changing the drawing operations of a Metafile may be alot more dificult. Hope this helps you.
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9005325
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from Slick812

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question