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怎么就不行了 大家帮我看看什么问题
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怎么就不行了 大家帮我看看什么问题
直接保存不是圆环状的啊
在 bit 里画好后,再放到 Panel 上,顺便保存。
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时 是没有句柄的 操作不了
刚开始写vcl 不大懂 前辈们指点指点啊!
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;
但是我放到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;
四个角可以是直角也可以是圆角, 已经实现直角,但是圆角的
实现不了,我做这步的目的是把图片变成圆环,然后放进bitmap里 然后切成4份去做圆角
我的思路是不是有问题,有谁有别的思路的吗?