i'm trying take screenshot of specific part of screen. here coordinates of part of screen want 'cut' :
left : 442 top : 440 right : 792 bottom : 520
that is, rectangle of width 350px , height of 80px. don't know how use copyrect achieve task, instead i'm getting blank image. here code :
function screenshot: boolean; var bild : tbitmap; c: tcanvas; rect_source, rect_destination : trect; begin c := tcanvas.create; bild := tbitmap.create; c.handle := getwindowdc(getdesktopwindow); try rect_source := rect(0, 0, screen.width, screen.height); rect_destination := rect(442,440,792,520); bild.width := 350; bild.height := 80; bild.canvas.copyrect(rect_destination, c, rect_source); bild.savetofile('c:\users\admin\desktop\screen.bmp'); releasedc(0, c.handle); bild.free; c.free; end; end;
what doing here copying whole screen , draw @ coordinate rect(442,440,792,520);
in new bitmap... off canvas.
the coordinate rect(442,440,792,520)
correspond part want source bitmap. want copy "inside" new bitmap, within rect rect(0,0,350,80)
you can adjust rect :
rect_source := rect(442,440,792,520); rect_destination := rect(0,0,350,80);
the rest of code seems correct.
Comments
Post a Comment