大佬教程收集整理的这篇文章主要介绍了Delphi – 我如何“就地”裁剪位图?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是否需要通过另一个位图或者可以在原始位图内完成此操作?
BitBlt
功能
试试这段代码.
procedure CropBitmap(InBitmap,OutBitMap : TBitmap; X,Y,W,H :Integer); begin OutBitMap.pixelFormat := InBitmap.pixelFormat; OutBitMap.Width := W; OutBitMap.Height := H; BitBlt(OutBitMap.Canvas.Handle,H,InBitmap.Canvas.Handle,X,SRCCOPY); end;
你可以用这种方式
Var Bmp : TBitmap; begin Bmp:=TBitmap.Create; try CropBitmap(Image1.Picture.bitmap,Bmp,10,150,150); //do something with the cropped image //Bmp.SaveToFile('Foo.bR_913_11845@p'); finally Bmp.Free; end; end;
如果要使用相同的位图,请尝试使用此版本的函数
procedure CropBitmap(InBitmap : TBitmap; X,H :Integer); begin BitBlt(InBitmap.Canvas.Handle,SRCCOPY); InBitmap.Width :=W; InBitmap.Height:=H; end;
并以这种方式使用
Var Bmp : TBitmap; begin Bmp:=Image1.Picture.bitmap; CropBitmap(Bmp,150); //do somehTing with the Bmp Image1.Picture.Assign(Bmp); end;
以上是大佬教程为你收集整理的Delphi – 我如何“就地”裁剪位图?全部内容,希望文章能够帮你解决Delphi – 我如何“就地”裁剪位图?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。