How to put shapes on top of a Metafiles?

Posted on 2003-02-24
Medium Priority
Last Modified: 2013-11-19
I start with either a bmp, jpg, emf or wmf (main image), then I want to put shapes onto of this image and output it as emf.  What is the best way to do this and how do I control the corrdinates of an emf?  Can I put icons or another smaller image onto of this main image and output it as emf?

Question by:Khaki
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
  • 2
  • 2
LVL 34

Accepted Solution

Slick812 earned 120 total points
ID: 8022933
hello Khaki, You do not say why you need an EMF type of Image, The Emf image is a vector type of image, and you say you want to use A Bitmap for this image, and a Bitmap is a Raster type of image (raster images have a record for EVERY pixel in the image, for the pixel colors. . . A vector Image only has drawing functions recorded and is a compleatly different kind of medium). . If you draw Bitmaps on a EMF image it will Lose it's vector qualities,  , I always try not to put any rastor images (bitmaps) onto vector images(MetaFiles).

here is some code to put shapes on a EMF and save it to file.

procedure TForm1.sbut_MakeEmfClick(Sender: TObject);
Emf1: TMetaFile;
AryPt: array[0..3] of TPoint;
Bmp1: TBitmap;
Emf1 := TMetafile.Create;
Bmp1 := TBitmap.Create;
Emf1.Enhanced := True;
Emf1.Width := 120;
Emf1.Height := 120;
Emf1.Transparent := True;

Bmp1.Canvas.Brush.Color := clBlack;
Bmp1.Width := 47;
Bmp1.Height := 27;

with TMetafileCanvas.Create(Emf1, 0) do
  Brush.Color := clRed;
  Brush.Color := clBlue;
  Pen.Color := clGreen;
  Brush.Color := clAqua;
  AryPt[0].x := 4;
  AryPt[0].y := 10;
  AryPt[1].x := 60;
  AryPt[1].y := 30;
  AryPt[2].x := 60;
  AryPt[2].y := 50;
  AryPt[3].x := 4;
  AryPt[3].y := 60;
{if you put a bitmap on a EMF it will NOT streatch the
bitmap pixels like a vector image and your file size will increase}
  Draw(4,90, Bmp1);
{if you cover an EMF with a bit map, it will act like a bitmap
you may as well use a Bitmap instead}
  {you can draw a TIcon with
   Draw(1,1, Icon1);}
PaintBox1.Canvas.Draw(20,20, Emf1);

- - - - - - - - - - - - - - - - - - - - - - - - -  -

if you are going to draw Bitmaps and Icons on this, maybe you should just use a Bitmap?
ask questions if you need more info

Author Comment

ID: 8056148
Is there a way to resize Metafile? Eg convert it to bmp or jpeg and resize it to 50% of original size?

Author Comment

ID: 8056149
Is there a way to resize Metafile? Eg convert it to bmp or jpeg and resize it to 50% of original size?
LVL 34

Expert Comment

ID: 8061516
look in delphi help for "StretchDraw" you can draw a Bitmap onto a Smaller Bitmap with StretchDraw, ,  since MetaFiles are vector images you can just resize them. . . if you can not figure this out I'll give you some code, there are Example code in the delphi help, , , there are plenty of pages here at EE about these things, , ,

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this Micro Tutorial viewers will learn the basic shortcuts and functions of Illustrator. The viewer will learn about the paintbrush tool, anchor points, font sizing, and more.
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 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