Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotating a bitmap 1

Status
Not open for further replies.

Kocky

Programmer
Oct 23, 2002
357
NL
Hello,

I want the following. I have a TImage component which contains a WMF (Windows Metafile) picture. I want to convert this WMF to a BMP. I tried to following code but it doesn't work.

procedure TfrmShowPreview.btnRotateClick(Sender: TObject);
var
AData: THandle;
APalette: HPALETTE;
AFormat: Word;
begin
Img.Picture.RegisterClipboardFormat(CF_BITMAP, TBitmap);
Img.Picture.RegisterClipboardFormat(CF_METAFILEPICT,
TMetafile);

Clipboard.Clear;
Img.Picture.SaveToClipboardFormat(AFormat, AData,
APalette);
Clipboard.SetAsHandle(CF_BITMAP, AData);
Img.Picture.Assign(nil);
Img.Picture.Assign(Clipboard);
end;
 
Code:
procedure TfrmShowPreview.btnRotateClick(Sender: TObject);
var
  DstBmp : TBitmap;
begin
  with Img.Picture do
  begin
    dstBmp := TBitmap.Create();
    dstBmp.Height := Metafile.Height;
    dstBmp.Width  := Metafile.Width;
    dstBmp.Canvas.StretchDraw(Rect(0, 0, Metafile.Width, Metafile.Height), Metafile);
    Assign(dstBmp);
    dstBmp.Free;
  end;
end;
Cheers

--- markus
 
Thanx !!
That solved the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top