ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Create Transparent PNG and Do Perspective Draw
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

KenR

United Kingdom
3 Posts

Posted - Dec 16 2015 :  07:54:11  Show Profile  Reply
Hi,

I would like to create a transparent png of a designated size and draw another image to the center of the new image keeping the perspective.

What is the best way of doing this?

Thanks,

Ken

w2m

USA
1990 Posts

Posted - Dec 16 2015 :  09:09:58  Show Profile  Reply
There are lots of ways to accomplish this, but this is one way to do it:

Uses iexHelperFunctions
procedure TForm1.Button1Click(Sender: TObject);
{ Add a layer, load a bitmap into the added layer, position the layer to the center of bitmap, then merge the layer }
var
  iLayer: Integer;
  iWidth: Integer;
  iHeight: Integer;
  iRGB: TRGB;
begin
  if IEWin7FileOpenDialog1.Execute then
  begin
    iWidth := ImageEnView1.IEBitmap.Width;
    iHeight := ImageEnView1.IEBitmap.Height;
    iLayer := ImageEnView1.LayersAdd;
    ImageEnView1.IO.LoadFromFile(IEWin7FileOpenDialog1.FileName);
    if ImageEnView1.IEBitmap.Width > iWidth then
      ImageEnView1.IEBitmap.IEConvertToThumbnail(iWidth div 2, -1, True,
        rfNone, False);
    if ImageEnView1.IEBitmap.Height > iHeight then
      ImageEnView1.IEBitmap.IEConvertToThumbnail(-1, iHeight div 2, True,
        rfNone, False);
    iRGB := ImageEnView1.IEBitmap.Pixels[0, ImageEnView1.IEBitmap.Height - 1];
    ImageEnView1.Proc.SetTransparentColors(iRGB, iRGB);
    ImageEnView1.Layers[iLayer].PosX := (ImageEnView1.Layers[0].Width div 2) -
      (ImageEnView1.IEBitmap.Width div 2);
    ImageEnView1.Layers[iLayer].PosY := (ImageEnView1.Layers[0].Height div 2) -
      (ImageEnView1.IEBitmap.Height div 2);
    ImageEnView1.Layers[iLayer].Width := ImageEnView1.IEBitmap.Width;
    ImageEnView1.Layers[iLayer].Height := ImageEnView1.IEBitmap.Height;
    ImageEnView1.LayersMergeAll();
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

KenR

United Kingdom
3 Posts

Posted - Dec 20 2015 :  04:37:23  Show Profile  Reply
Many thanks.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: