Багфикс скриншота экрана с новым форматом изображения

This commit is contained in:
Igor Timofeev 2015-10-06 14:54:36 +03:00
parent c0638887ce
commit 59829c7c5c
2 changed files with 20 additions and 1 deletions

View File

@ -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)

View File

@ -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()