Link to home
Start Free TrialLog in
Avatar of ST3VO
ST3VOFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Save 2 TImages as 1 Image.

Hi all,

I've got 2 TImages.

Image1 loads an image on a Frame
Image2 load a Picture.

They are already positioned.

What I need to do need is the Save this 2 TImages as 1 Image.

How could I do this please?

THanks

ST3VO
Avatar of KaRmA90
KaRmA90

Just out of interest what is a timage? What format are these files? What program are you using?

Sorry if I'm being ignorant I've done a photo/picture editing and never herd of a Timage
Avatar of ST3VO

ASKER

TImage is a Delphi component to handle images.

I am using 2.

The frame is a PNG and the center images are JPG.

You can do it like this

procedure TForm1.Button1Click(Sender: TObject);
var
  bmp: TBitmap;
  jpg: TJPegImage;
begin
  bmp := TBitmap.Create;
  jpg := TJPegImage.Create;
  bmp.Assign(Image1.Picture.Graphic);
  bmp.Canvas.Draw(10,10,Image2.Picture.Graphic);
  bmp.SaveToFile('d:\test.bmp');        // save as bitmap
  jpg.Assign(bmp);
  jpg.SaveToFile('d:\test.jpg');           // save as jpg
  jpg.Free;
  bmp.Free;
end;
Avatar of ST3VO

ASKER

Hi mokule,

I'm looking at your code and it saves 2 files.

I have 2 TImages which I need to save as just 1 Image.

The 2 Images are already loaded into the TImages. I just need to Merge both and save them as Jpg.

Hope this helps!

Cheers :o)

ST3VO
Read comments in program please.
It saves merged image but in to formats.

you need to "compose" the images, the frame on top of the actual picture, right ?
Avatar of ST3VO

ASKER

You're right mokule!

Sorry about that!

I just have a small problem with it.

Image1 - Contains the Frame and it's 256 Height x 512 Width.
Image2 - Contains the Picture which is a image the frame bit on top of Image1.

As they did'nt save in place with Canvas 10, 10, I changed it to the Height and Width of the Frame image and I can only see the framed image now and not both.

Any ideas why please?

 
In my example the smaller image must be on top of bigger.
I've assumed a frame is rectangular and without transparency
Avatar of ST3VO

ASKER

Update:

OK I changed the Canvas to 0,0 and it's now in position BUT the Frame image is been saved to it's original size and not the stretched size :o/

Avatar of ST3VO

ASKER

Ref: I've assumed a frame is rectangular and without transparency

Yes It's rectangular but the Frame has transparency although I'm not too bothered about that. I just the the images to look as they do on the form before saving.
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ST3VO

ASKER

Perfect!!! Thanks a million :o)