Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 744
  • Last Modified:

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
0
ST3VO
Asked:
ST3VO
1 Solution
 
KaRmA90Commented:
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
0
 
ST3VOAuthor Commented:
TImage is a Delphi component to handle images.

I am using 2.

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

0
 
mokuleCommented:
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;
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ST3VOAuthor Commented:
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
0
 
mokuleCommented:
Read comments in program please.
It saves merged image but in to formats.
0
 
xr1140Commented:

you need to "compose" the images, the frame on top of the actual picture, right ?
0
 
ST3VOAuthor Commented:
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?

 
0
 
mokuleCommented:
In my example the smaller image must be on top of bigger.
0
 
mokuleCommented:
I've assumed a frame is rectangular and without transparency
0
 
ST3VOAuthor Commented:
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/

0
 
ST3VOAuthor Commented:
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.
0
 
mokuleCommented:
So do it like this.
It is saved as bitmap here.
if You want to save as jpeg use conversion from previous example

procedure TForm1.Button1Click(Sender: TObject);
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  bmp.Width := Image1.Width;
  bmp.height := Image1.height;
  bmp.PixelFormat := pf24bit;
  BitBlt(bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,Form1.Canvas.Handle,Image1.Left,Image1.Top,SRCCOPY);
  bmp.SaveToFile('d:\test2.bmp');
  bmp.Free;
end;
0
 
ST3VOAuthor Commented:
Perfect!!! Thanks a million :o)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now