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
 How to create a frame around the picture?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lostman

5 Posts

Posted - Feb 16 2013 :  09:01:22  Show Profile  Reply
Hi,
how to create a frame around the picture?

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

Thanks
Petr

w2m

USA
1990 Posts

Posted - Feb 16 2013 :  09:43:34  Show Profile  Reply
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
Go to Top of Page

lostman

5 Posts

Posted - Feb 16 2013 :  11:27:06  Show Profile  Reply
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.

Go to Top of Page

w2m

USA
1990 Posts

Posted - Feb 16 2013 :  16:20:16  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: