Solved

remove the background from EMF

Posted on 2002-05-08
4
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month4 days, 22 hours left to enroll

636 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