mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Add support for tiff and gif format in screensaver (#4250)
This commit is contained in:
@@ -15,6 +15,14 @@ local _ = require("gettext")
|
||||
local Screen = Device.screen
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local screensaver_provider = {
|
||||
["jpg"] = true,
|
||||
["jpeg"] = true,
|
||||
["png"] = true,
|
||||
["gif"] = true,
|
||||
["tif"] = true,
|
||||
["tiff"] = true,
|
||||
}
|
||||
local default_screensaver_message = _("Sleeping")
|
||||
local Screensaver = {}
|
||||
|
||||
@@ -29,11 +37,8 @@ local function getRandomImage(dir)
|
||||
if ok then
|
||||
for entry in iter, dir_obj do
|
||||
if lfs.attributes(dir .. entry, "mode") == "file" then
|
||||
local extension =
|
||||
string.lower(string.match(entry, ".+%.([^.]+)") or "")
|
||||
if extension == "jpg"
|
||||
or extension == "jpeg"
|
||||
or extension == "png" then
|
||||
local extension = string.lower(string.match(entry, ".+%.([^.]+)") or "")
|
||||
if screensaver_provider[extension] then
|
||||
i = i + 1
|
||||
pics[i] = entry
|
||||
end
|
||||
@@ -113,7 +118,7 @@ function Screensaver:chooseFile()
|
||||
file_filter = function(filename)
|
||||
local util = require("util")
|
||||
local suffix = util.getFileNameSuffix(filename)
|
||||
if suffix == "jpeg" or suffix == "jpg" or suffix == "png" then
|
||||
if screensaver_provider[suffix] then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -128,7 +128,7 @@ end
|
||||
function ImageWidget:_loadfile()
|
||||
local itype = string.lower(string.match(self.file, ".+%.([^.]+)") or "")
|
||||
if itype == "png" or itype == "jpg" or itype == "jpeg"
|
||||
or itype == "tiff" then
|
||||
or itype == "tiff" or itype == "tif" or itype == "gif" then
|
||||
-- In our use cases for files (icons), we either provide width and height,
|
||||
-- or just scale_for_dpi, and scale_factor should stay nil.
|
||||
-- Other combinations will result in double scaling, and unexpected results.
|
||||
|
||||
Reference in New Issue
Block a user