diff --git a/lib/event.lua b/lib/event.lua index 5300811c..7e003e36 100644 --- a/lib/event.lua +++ b/lib/event.lua @@ -292,7 +292,7 @@ end function event.takeScreenshot() if keyboard.isKeyDown(100) or keyboard.isKeyDown(183) then computer.beep(1500) - local screenshotPath = "screenshot.jpg" + local screenshotPath = "screenshot.pic" image.screenshot(screenshotPath) computer.beep(2000) computer.beep(2000) diff --git a/lib/image.lua b/lib/image.lua index f08df030..2935543e 100644 --- a/lib/image.lua +++ b/lib/image.lua @@ -433,6 +433,25 @@ local function loadOldPng(path) return massiv end +--Сделать скриншот экрана и сохранить его по указанному пути +function image.screenshot(path) + local picture = {} + local foreground, background, symbol + picture.width, picture.height = gpu.getResolution() + + for j = 1, picture.height do + for i = 1, picture.width do + foreground, background, symbol = gpu.get(i, j) + table.insert(picture, background) + table.insert(picture, foreground) + table.insert(picture, 0x00) + table.insert(picture, symbol) + end + end + + image.save(path, picture) +end + ------------------------------------------ Примеры работы с библиотекой ------------------------------------------------ -- ecs.prepareToExit()