Can only modify an image if it contains a bitmap
Image1装载了JPG文件后下面都报错,因为。
Image1.Canvas.CopyRect(drect,Image1.Canvas,srect);
Image1.Picture.Bitmap.Canvas.CopyRect(drect,Image1.Canvas,srect);
以上2行都报错。只是在image1的picture为bmp的时候适用。
Image1.Canvas.MoveTo(1,1);
Image1.Canvas.LineTo(100,100);
这样也报错,但是未装载jpg文件或者装载的bmp文件就不报错了。
如果Image1.Picture.Graphic不是TBitmap,Image1.Canvas是不可使用的。
procedure TForm1.Button1Click(Sender: TObject); var MyRgn: HRGN; begin MyRgn := CreateRectRgn(100,100,200,200); SelectClipRgn(Image1.Canvas.Handle,MyRgn); Image1.Canvas.Brush.Color := clRed; Image1.Canvas.FillRect(Image1.Canvas.ClipRect); Image1.Invalidate; SelectClipRgn(Image1.Canvas.Handle, HRGN(nil)); DeleteObject(MyRgn); end;
Image1.Canvas.Brush.Color := clRed; Image1.Canvas.Brush.Style := bsDiagCross; Image1.Canvas.Ellipse(0, 0, Image1.Width, Image1.Height);