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 crop image and save

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
aftereffectniko Posted - Jun 26 2013 : 09:40:20
i'm trying to make photo frame software , there is 2 layer , the first layer is user photo the second layer is frame png.. when i try to merje and save the picture , the first layer get big like in the attached picture, i want to cut..

4   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Jun 27 2013 : 06:56:49
You can try this, but I can not guarantee that it will work correctly with your pictures and frames. That said here is some code to merge two layers into a framed picture:
procedure TForm1.Frame1Click(Sender: TObject);
{ Combine two layers into one. layer 0 contains the picture, layer 1 contains the frame.  The area
  inside the frame image must be transparent or have an alpha of 0.  The frameheight is estimated
  from on the the location of the first pixel in layer 1 that has an alpha value of 0.  The layers
  are repositioned (PosX and PosY) to fit the frame in layer 1 to the picture in layer 0.  This may
  not perform correctly with some frame bitmaps because the estimate of the frame height is just
  that... an estimate, however my testing with a number of picture sizes and frames produces good
  results.  }
var
  i: integer;
  iAlpha: integer;
  iFrameHeight: integer;
begin
  { Get the first pixel with alpha = 0, then estimate the iFrameHeight }
  for i := 0 to ImageEnView1.Layers[1].Bitmap.Height - 1 do
  begin
     iAlpha := ImageEnView1.Layers[1].Bitmap.Alpha[ImageEnView1.Layers[1].Bitmap.Width div 2, i];
     if iAlpha = 0 then
     begin
        iFrameHeight := i*10;
        break;
     end
     else
       iFrameHeight := 100;
  end;
  { Photo is in layer 0, so resize layer 0 to provide room for the frame in layer 1 }
  ImageEnView1.Layers[0].PosX := -iFrameHeight;
  ImageEnView1.Layers[0].PosY := -iFrameHeight;
  ImageEnView1.Layers[0].Width := ImageEnView1.Layers[0].Bitmap.Width;
  ImageEnView1.Layers[0].Height := ImageEnView1.Layers[0].Bitmap.Height;
  { Frame is in Layer 1 so stretch the layer to fit the photo in layer 0 }
  ImageEnView1.Layers[1].PosX := -iFrameHeight * 2;
  ImageEnView1.Layers[1].PosY := -iFrameHeight * 2;
  ImageEnView1.Layers[1].Width := ImageEnView1.Layers[0].Bitmap.Width + iFrameHeight * 2;
  ImageEnView1.Layers[1].Height := ImageEnView1.Layers[0].Bitmap.Height + iFrameHeight * 2;
  { Combine the layers }
  ImageEnView1.LayersMergeAll;
  ImageEnView1.Fit;
end;


35.07 KB


1.2 KB


39.72 KB
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
w2m Posted - Jun 26 2013 : 13:20:24
Can you upload the original image you want to frame?
Can you upload the frame image?
Finally can you upload an image of what you want the framed image to look like?

William Miller
Prg Posted - Jun 26 2013 : 12:20:40
So, you can do it without any "manual" calculating and cropping:

ImageEnView1.LayersInsert(0);
ImageEnView1.Layers[0].Width := ImageEnView1.Layers[2].Width;
ImageEnView1.Layers[0].Height := ImageEnView1.Layers[2].Height;
ImageEnView1.Layers[0].Visible := False;
ImageEnView1.Layers[1].Cropped := True;
ImageEnView1.LayersMergeAll;
w2m Posted - Jun 26 2013 : 10:03:12
Show the code you are using.

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