Solved

remove the background from EMF

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 76
How to define IfThen functions in one common unit? 4 54
Create a path if not exists 7 78
firemonkey keyboard covers the controls 1 26
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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