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
 How to create a frame around the picture?

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
lostman Posted - Feb 16 2013 : 09:01:22
Hi,
how to create a frame around the picture?

some functionality such as:
http://www.hochstrasser.org/wiki/pmwiki.php/Delphi/FrameFun

Thanks
Petr
3   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Feb 16 2013 : 16:20:16
The frame in the link does not look anything like your second request... non-the-less the best way to do this is probably by loading the frame in a layer, then position the layer correctly with the mouse.

The image frame you posted is very complex, which makes it dificult to automatically position the frame because the frame has a transparent top border of about 200 pixels and the frame is of varying dimensions.

If you ised a frame with a uniform width on all sides it would be much easier to position the image.
The frame that you use should be a 32-bit png image with an alpha value of 0 on the outside of the border as well as inside the border so the image in layer 0 is visible.

Here is a way to do it:
procedure TForm1.OpenFrame1Click(Sender: TObject);
var
  iFilename: string;
  iWidth: integer;
  iHeight: integer;
  iLayer: integer;
begin
  iWidth := ImageEnView1.Bitmap.Width;
  iHeight := ImageEnView1.Bitmap.Height;
  iLayer := ImageEnView1.LayersAdd;
  OpenPictureDialog1.Filter := Graphics.GraphicFilter(TGraphic);
  if OpenPictureDialog1.Execute then
  begin
    iFilename := OpenPictureDialog1.FileName;
    ImageEnView1.Layers[0].PosX := 0;
    ImageEnView1.Layers[0].PosY := 0;
    ImageEnView1.Layers[iLayer].PosX := -40;
    ImageEnView1.Layers[iLayer].PosY := - 232;
    ImageEnView1.Layers[iLayer].Width := iWidth + 80;
    ImageEnView1.Layers[iLayer].Height := iHeight + 276;
    ImageEnView1.IO.LoadFromFile(iFilename);
    ImageEnView1.Zoom := 100;
  end;
end;

This code is demonstrated in a project which you may download here:
https://dl.dropbox.com/u/3695621/FrameLayers.zip

A screenshot of the framed image is shown below:

1151.22 KB

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
lostman Posted - Feb 16 2013 : 11:27:06
Thank you for your answer.

Maybe I said it wrong. I need to combine two images together. the first frame and the second picture into the frame.

w2m Posted - Feb 16 2013 : 09:43:34
See the AddBorder and Copyright demos in the samples folder. To add a shadow around the frame you probably have to add ImageEnView1.Proc.AddSoftShadow after the frame is added in the AddBorder demo.

You can also try this:
procedure TForm1.CreateBorderedImage;
var
  iOrigWidth: integer;
  iOrigHeight: integer;
begin
  ImageEnView2.Clear;
  ImageEnView2.Assign(ImageEnView1);
  iOrigWidth := ImageEnView1.IEBitmap.Width;
  iOrigHeight := ImageEnView1.IEBitmap.Height;
  // set background color
  ImageEnView2.BackGround := BorderColor1.EditValue;
  ImageEnView2.RemoveAlphaChannel();
  // Symmetric
  ImageEnView2.Proc.ImageResize(iOrigWidth + BorderWidth1.EditValue * 2, iOrigHeight +
    BorderWidth1.EditValue * 2, iehCenter,
    ievCenter);
  if AddShadow1.Checked then
    ImageEnView2.Proc.AddSoftShadow(BorderWidth1.EditValue, 5, 5, true, clblack, 100);
  // restore background color
  ImageEnView2.Background := clBtnFace;
  ImageEnView2.Update;
end;

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html