tmppanel := TPanel.Create(nil);
     tmppanel.Parent := Self;
     tmppanel.Width := 100;
     tmppanel.Height := 100;
     tmppanel.Top := 20;
     tmppanel.Left := 20;     aimage := TImage.Create(nil);
     aimage.Parent:= tmppanel;
     aimage.Align := alClient;
     aimage.Picture.Bitmap.LoadFromResourceName(HInstance, 'GROUNDBMP');     x:= CreateEllipticRgn(0, 0, tmppanel.Width, tmppanel.Height);
     y:= CreateEllipticRgn(w, w, tmppanel.Width - w, tmppanel.Height - w);
     CombineRgn(y, x, y, RGN_XOR);
     SetWindowRgn(tmppanel.Handle, y, True);
     bit := TBitmap.Create;
     bit.Width := tmppanel.Width;
     bit.Height := tmppanel.Height;
     BitBlt(bit.Canvas.Handle, 0, 0, tmppanel.Width, tmppanel.Height, GetDC(tmppanel.Handle), 0, 0, SRCCOPY);
     bit.SaveToFile('C:\Dest5.bmp');我想把整个panel保存到图片上 怎么老是空的
在程序里可以实现  怎么在vcl怎么就不行了 大家帮我看看什么问题

解决方案 »

  1.   

    怎么搞这么复杂,你都创建了TImage了,那就直接保存就是了
      

  2.   

    我的思路是这样的 我现在panel上放一个图片 然后变成圆环状,再保存起来圆环状图片
    直接保存不是圆环状的啊
      

  3.   

    那就不要在 Panel 上画。
    在 bit 里画好后,再放到 Panel 上,顺便保存。
      

  4.   

    能给我个实例吗? 
     x:= CreateEllipticRgn(0, 0, tmppanel.Width, tmppanel.Height);
      y:= CreateEllipticRgn(w, w, tmppanel.Width - w, tmppanel.Height - w);
      CombineRgn(y, x, y, RGN_XOR);
      SetWindowRgn(tmppanel.Handle, y, True);
    在这里操作image时 是没有句柄的 操作不了
      

  5.   

    有没有人搞过这个啊  是不是在vcl里不给这样写啊
    刚开始写vcl 不大懂  前辈们指点指点啊!
      

  6.   

    要搞圆形,用GDI+编程啊,那个更快
      

  7.   

    既然你已加分,那我就给你贴出其中一种方法吧:新建个工程,在窗体上放一个panel,还可以在panel上放任意东西。然后再建个按扭,按扭单击事件如下:procedure TForm1.Button1Click(Sender: TObject);
    var Bmp: TBitMap;i: integer;SourRect: TRect;
    begin
      SourRect := panel1.ClientRect;
      BMP := TBitMap.Create;
      BMP.PixelFormat := pf24bit;
      BMP.Width := SourRect.Right;
      BMP.Height := SourRect.Bottom;
      BitBlt(BMP.Canvas.Handle, 0, 0, BMP.Width, BMP.Height, Canvas.Handle, panel1.Left, panel1.Top,SRCCOPY);
      BMP.SaveToFile('MyPic.bmp');
      BMP.Free;
    end;
      

  8.   

    汗 跟我的还是一样哦  就在新的工程里都没问题
    但是我放到vcl里  创建的时候 就保存图片又空了procedure TBorderImagePanel.DrawPanelArc;
    var
      x, y: HRgn;
      bit: tBitmap;
      tmppanel: TPanel;
      aimage: TImage;
      w: Integer;
      SourRect: TRect;
    begin
      w := Self.BorderWidth;
      try
        begin
          tmppanel := TPanel.Create(nil);
          tmppanel.Parent := Self;
          tmppanel.Width := 100;
          tmppanel.Height := 100;
          tmppanel.Top := 20;
          tmppanel.Left := 20;
          aimage := TImage.Create(nil);
          aimage.Parent:= tmppanel;
          aimage.Align := alClient;
          aimage.Picture.Bitmap.LoadFromResourceName(HInstance, 'GROUNDBMP');      x := CreateEllipticRgn(0, 0, tmppanel.Width, tmppanel.Height);
          y := CreateEllipticRgn(w, w, tmppanel.Width - w, tmppanel.Height - w);
          CombineRgn(y, x, y, RGN_XOR);
          SetWindowRgn(tmppanel.Handle, y, True);
         {
          bit := TBitmap.Create;
          bit.Width := tmppanel.Width;
          bit.Height := tmppanel.Height;
          BitBlt(bit.Canvas.Handle, 0, 0, tmppanel.Width, tmppanel.Height, GetDC(tmppanel.Handle), 0, 0, SRCCOPY);
          bit.SaveToFile('C:\Dest5.bmp');
                                           }
         SourRect := tmppanel.ClientRect;
         bit := TBitMap.Create;
         bit.PixelFormat := pf24bit;
         bit.Width := SourRect.Right;
         bit.Height := SourRect.Bottom;
         BitBlt(bit.Canvas.Handle, 0, 0, bit.Width, bit.Height, Canvas.Handle, tmppanel.Left, tmppanel.Top,SRCCOPY);
         bit.SaveToFile('C:\MyPic.bmp');
         bit.Free;
        end;
      finally  end;end;
      

  9.   

    我的目的就是做成相框一样  但是周边都是图片 可以改变大小 
    四个角可以是直角也可以是圆角, 已经实现直角,但是圆角的
    实现不了,我做这步的目的是把图片变成圆环,然后放进bitmap里 然后切成4份去做圆角
    我的思路是不是有问题,有谁有别的思路的吗?