Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by Edgemeal
Excellent question! I messed around with that a little bit before, PNG's look OK but I was never really sure I'm doing it correctly , would love to get Julian's feedback!
Capture screen area to PNG,..
Code:
function CaptureScreenArea(x,y,w,h,filename)
sourceHDC = reaper.JS_GDI_GetScreenDC()
destBmp = reaper.JS_LICE_CreateBitmap(true,w,h)
destDC = reaper.JS_LICE_GetDC(destBmp)
reaper.JS_GDI_Blit(destDC, 0, 0, sourceHDC, x, y, w, h)
reaper.JS_LICE_WritePNG(filename, destBmp, false)
reaper.JS_LICE_DestroyBitmap(destBmp)
end
Capture a window to PNG,..
Code:
function GetBounds(hwnd)
local _, left, top, right, bottom = reaper.JS_Window_GetRect(hwnd)
return left, top, right-left, bottom-top
end
function CaptureWindow(windowTitle, filename, win10)
window = reaper.JS_Window_FindTop(windowTitle, true)
if not window then reaper.MB('Window not found!','Capture Error',0) return end
sourceHDC = reaper.JS_GDI_GetWindowDC(window)
_,_,w,h = GetBounds(window)
srcx,srcy = 0,0
if win10 then srcx=7 w=w-14 h=h-7 end -- workaround for invisible Win10 borders.
dest_bmp = reaper.JS_LICE_CreateBitmap(true,w,h)
destDC = reaper.JS_LICE_GetDC(dest_bmp)
-- copy source to dest & write PNG
reaper.JS_GDI_Blit(destDC, 0, 0, sourceHDC, srcx, srcy, w, h)
reaper.JS_LICE_WritePNG(filename, dest_bmp, false)
-- clean up resources
reaper.JS_GDI_ReleaseDC(window, sourceHDC)
reaper.JS_LICE_DestroyBitmap(dest_bmp)
end
|
Thank You, Savior of the Universe
|