Solved

remove the background from EMF

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

15 Experts available now in Live!

Get 1:1 Help Now