Solved

remove the background from EMF

Posted on 2002-05-08
4
474 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 33

Accepted Solution

by:
Slick812 earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now