crop and align inserted BMP in Delphi -
i want crop , align inserted bmp clipboard. i'm trying 2 days still nothing workable...
procedure tform1.act1execute(sender: tobject); var bmp : tbitmap; begin bmp := tbitmap.create; bmp.assign(clipboard); bmp.setsize(400,200); img1.picture.graphic := bmp; bmp.free; end; procedure tform1.act1update(sender: tobject); begin (sender taction).enabled := clipboard.hasformat(cf_bitmap); end; end.
if understand right, need center bitmap in image control?
it's simple - set img1.center := true
to crop bitmap need code this:
procedure cropbitmap(bmp: tbitmap; const croprect: trect); var cropbmp: tbitmap; begin cropbmp := tbitmap.create; try cropbmp.width := croprect.right - croprect.left; cropbmp.height := croprect.bottom - croprect.top; cropbmp.canvas.copyrect( rect(0, 0, cropbmp.width, cropbmp.height), bmp.canvas, croprect ); bmp.assign(cropbmp); cropbmp.free; end; end;
Comments
Post a Comment