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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Create Transparent PNG and Do Perspective Draw

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
KenR Posted - Dec 16 2015 : 07:54:11
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
2   L A T E S T    R E P L I E S    (Newest First)
KenR Posted - Dec 20 2015 : 04:37:23
Many thanks.
w2m Posted - Dec 16 2015 : 09:09:58
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