两幅图片,一张作为外观装饰,一张人物,人物可以移动,旋转,缩放。处理完后将其合并并且可以打印

解决方案 »

  1.   

    将两个图形,都画到一般 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;
      

  2.   

    GDI+,支持透明通道,支持缩放
      

  3.   

    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);
      

  4.   


    我手上有类似的多个项目.....都是采用timage32+ gdi+ 处理的,基于动作命令的设计,支持撤消重复功能
      

  5.   

    稻草人 用的DELPHI是什么版本的 
      

  6.   

    7.0
    控件是这个
    graphics32-1-8-3
      

  7.   

    我的graphics32-1-8-3,怎么找不到GR32_RotLayer这个单元
      

  8.   

    我找了好几个 graphics32-1-8-3里面都没有GR32_RotLayer这个单元,怎么回事?
      

  9.   

    在Examples\Vcl 目录下,你不会用搜索?
      

  10.   

    Examples\Vcl 这里面的就是最好的例子..
    Examples\Vcl\Layers\ImgView_Layers_Ex
    这个就是图层使用的
      

  11.   

    楼主你要熟悉Canvas画布操作即可,如果想支持多种格式需要用到GDI+。图像合并是很简单的东西,DELPHI有现成的方法,向画布画出即可,无论你有多少图片都可以画到画布上,然后保存画布,就等于合并了。
      

  12.   

    我的 GDI+中的 TGpImage 怎么没有width,height属性,是不是我下载的GDI+ 不对