将两个IMAGE保存在同一个bmp中(100分)

  • 主题发起人 主题发起人 leeloo
  • 开始时间 开始时间
L

leeloo

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何将两个Image保存在同一个BMP中?
谢谢
 
呵呵!来赚点分!
OriBmp:TBitmap;

OriBmp.LoadFromFile('E:/Demo.bmp');
OriBmp.Canvas.Draw(logoX,logoY,Image1.Picture.Graphic);
OriBmp.SaveToFile('E:/aa.bmp');
aa.bmp即为合成后的BMP
 
cdyxl
我觉得这个方法不太好
比如我要是想拖动Image1怎么办
那样岂不是很麻烦?
 
有什么麻烦!你要拖动IMAGE1,那你就响应MOUSEDOWN,MOUSEMOVE,MOUSEUP事件不就搞定!
我现在就是这样做的!而且IMAGE1还可以控制透明!
呵呵!试一试啦!
 
此代码可实现你的要求:(www.huasoft.net)
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls, Mask, Grids, Buttons, dbcgrids,
AppEvnts, Menus;

type
TForm1 = class(TForm)
Image: TImage;
Image1: TImage;
MainMenu1: TMainMenu;
N1: TMenuItem;
Image2: TImage;
N2: TMenuItem;
N3: TMenuItem;
procedure ImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{自定义过程}
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
mx,my:Integer;

implementation

{$R *.dfm}


procedure TForm1.ImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if shift<>[] then
with TImage(Sender) do
begin
Left:=Left+x-mx;
Top:=Top+y-my;
end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.DoubleBuffered:=true;
end;


procedure TForm1.N1Click(Sender: TObject);
begin
Image2.Picture.SaveToFile('c:/合成.bmp');
showmessage('图像已经存到C:/合成.bmp');
end;

procedure TForm1.N3Click(Sender: TObject);
begin
Image2.Width:=1;Image2.Height:=1;
Image2.Visible:=false;
end;

procedure TForm1.N2Click(Sender: TObject);
begin
Image2.Width:=form1.ClientWidth;
Image2.Height:=form1.ClientHeight;
Image2.Picture:=nil;
Image2.Canvas.Draw(Image.Left,Image.Top,Image.Picture.Graphic);
Image2.Canvas.Draw(Image1.Left,Image1.Top,Image1.Picture.Graphic);
Image2.Visible:=true;
Image2.BringToFront;
end;

procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mx:=x;
my:=y;
if ssright in shift then Image.BringToFront;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mx:=x;
my:=y;
if ssright in shift then Image1.BringToFront;
end;

end.
 
太感谢了
 
多人接受答案了。
 
后退
顶部