想做一个类似大头贴的软件,不知道如何将图像框和头像的合并 两幅图片,一张作为外观装饰,一张人物,人物可以移动,旋转,缩放。处理完后将其合并并且可以打印 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将两个图形,都画到一般 bitmap的Canvas中,然后保存bitmap,比如var bmp :TBitmap;begin bmp := TBitmap.Create; bmp.Width := 100; bmp.Height := 100; bmp.Canvas.Ellipse(0,0,50,50);//画人头 bmp.Canvas.FillRect(Rect(10,10,20,20)); //画框 bmp.SaveToFile('c:\1.bmp');end; GDI+,支持透明通道,支持缩放 var FImgView : TImage32; aLayer : TRotLayer;begin FImgView := timage32.create(self); aLayer := TRotLayer.Create(FImgView.Layers); with alayer do begin Bitmap.SetSize(width,height); Angle := FAngle; //整个图像的角度 Bitmap.BeginUpdate; Bitmap.DrawMode := dmBlend; //FDrawX,FDrawY,FDrawW,FDrawH 图像在图层中的坐标和大小 DrawImage(FFileName,Bitmap.Canvas.Handle,GpRect(FDrawX,FDrawY,FDrawW,FDrawH)); SetBorderTransparent(Bitmap, Rect(0, 0, Bitmap.Width + 1, Bitmap.Height + 1 )); BitmapCenter := FloatPoint(Bitmap.Width / 2, Bitmap.Height / 2); Bitmap.StretchFilter := sfLinear; //FLayerX,FLayerY 图层在FImgView 坐标系中的坐标 Position := FloatPoint(Bitmap.Width / 2 + FLayerX,Bitmap.Height / 2 + FLayerY); Bitmap.MasterAlpha := FAlpha;//整体通明度 Bitmap.EndUpdate; Bitmap.Changed; MouseEvents := True; //响应鼠标事件 OnMouseDown := OnLayerMouseDown; OnMouseMove := OnLayerMouseMove;//移动 OnMouseUp := OnLayerMouseUp; end;end;//通过GDI+中的 TGpMatrix 可将图像在目标画布上旋转procedure DrawImage(sFile : string;DC: HDC;aRect : TGpRectF); var Gd : TGpGraphics; GpBmp : TGpBitmap;begin if not FileExists(sFile) then Exit; Gd := TGpGraphics.Create(DC); GpBmp := TGpBitmap.Create(sFile); Gd.DrawImage(GpBmp,aRect,0,0,GpBmp.Width,GpBmp.Height,utPixel); Gd.Free; GpBmp.Free;end;先画人像,再画边框保存: var Bitmap: tbitmap32;FImgView.PaintTo(Bitmap,Bitmap.ClipRect); 我手上有类似的多个项目.....都是采用timage32+ gdi+ 处理的,基于动作命令的设计,支持撤消重复功能 稻草人 用的DELPHI是什么版本的 7.0控件是这个graphics32-1-8-3 我的graphics32-1-8-3,怎么找不到GR32_RotLayer这个单元 我找了好几个 graphics32-1-8-3里面都没有GR32_RotLayer这个单元,怎么回事? 在Examples\Vcl 目录下,你不会用搜索? Examples\Vcl 这里面的就是最好的例子..Examples\Vcl\Layers\ImgView_Layers_Ex这个就是图层使用的 楼主你要熟悉Canvas画布操作即可,如果想支持多种格式需要用到GDI+。图像合并是很简单的东西,DELPHI有现成的方法,向画布画出即可,无论你有多少图片都可以画到画布上,然后保存画布,就等于合并了。 我的 GDI+中的 TGpImage 怎么没有width,height属性,是不是我下载的GDI+ 不对 问一个序号排序的问题 求教:网页中呼出即时通讯软件 求救:我用TServerSocket和ClientSocket做个一个文件发送程序,老有错误,大家进来看看 谁帮我看看什么地方有错啊,谢先。 如何在程序运行的时候往Image组件中载入jpg图像? 请问,如何使程序在系统托盘上的图标有动态效果? 请各位高手看看这个问题! 我是初学者,请问各位高手,如何安装空间啊? 怎样这样给表命名? 如何向别的窗口发按键信息?KeyPress delphi dbgrideh delphi数据库连接
bmp :TBitmap;
begin
bmp := TBitmap.Create;
bmp.Width := 100;
bmp.Height := 100;
bmp.Canvas.Ellipse(0,0,50,50);//画人头
bmp.Canvas.FillRect(Rect(10,10,20,20)); //画框
bmp.SaveToFile('c:\1.bmp');
end;
aLayer : TRotLayer;
begin
FImgView := timage32.create(self);
aLayer := TRotLayer.Create(FImgView.Layers);
with alayer do
begin
Bitmap.SetSize(width,height);
Angle := FAngle; //整个图像的角度
Bitmap.BeginUpdate;
Bitmap.DrawMode := dmBlend;
//FDrawX,FDrawY,FDrawW,FDrawH 图像在图层中的坐标和大小
DrawImage(FFileName,Bitmap.Canvas.Handle,GpRect(FDrawX,FDrawY,FDrawW,FDrawH));
SetBorderTransparent(Bitmap, Rect(0, 0, Bitmap.Width + 1, Bitmap.Height + 1 ));
BitmapCenter := FloatPoint(Bitmap.Width / 2, Bitmap.Height / 2); Bitmap.StretchFilter := sfLinear;
//FLayerX,FLayerY 图层在FImgView 坐标系中的坐标
Position := FloatPoint(Bitmap.Width / 2 + FLayerX,Bitmap.Height / 2 + FLayerY);
Bitmap.MasterAlpha := FAlpha;//整体通明度
Bitmap.EndUpdate;
Bitmap.Changed;
MouseEvents := True; //响应鼠标事件
OnMouseDown := OnLayerMouseDown;
OnMouseMove := OnLayerMouseMove;//移动
OnMouseUp := OnLayerMouseUp;
end;
end;//通过GDI+中的 TGpMatrix 可将图像在目标画布上旋转
procedure DrawImage(sFile : string;DC: HDC;aRect : TGpRectF);
var Gd : TGpGraphics;
GpBmp : TGpBitmap;
begin
if not FileExists(sFile) then Exit;
Gd := TGpGraphics.Create(DC);
GpBmp := TGpBitmap.Create(sFile);
Gd.DrawImage(GpBmp,aRect,0,0,GpBmp.Width,GpBmp.Height,utPixel);
Gd.Free;
GpBmp.Free;
end;先画人像,再画边框保存:
var Bitmap: tbitmap32;
FImgView.PaintTo(Bitmap,Bitmap.ClipRect);
我手上有类似的多个项目.....都是采用timage32+ gdi+ 处理的,基于动作命令的设计,支持撤消重复功能
控件是这个
graphics32-1-8-3
Examples\Vcl\Layers\ImgView_Layers_Ex
这个就是图层使用的