From 59829c7c5c3bf20bbeb6ebf4a3c081d3484e03e0 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Tue, 6 Oct 2015 14:54:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B0=D0=B3=D1=84=D0=B8=D0=BA=D1=81=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BD=D1=88=D0=BE=D1=82=D0=B0=20=D1=8D?= =?UTF-8?q?=D0=BA=D1=80=D0=B0=D0=BD=D0=B0=20=D1=81=20=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=BC=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=BE=D0=BC?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/event.lua | 2 +- lib/image.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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()