Change scaling algorithm for performance
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import strformat
|
||||
# Package
|
||||
|
||||
version = slurp("src/version")
|
||||
version = "0.2.0"
|
||||
author = "luxick"
|
||||
description = "Play an image slide show from different sources"
|
||||
license = "GPL-2.0"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os, sets, random, httpClient, json, strformat, options, deques
|
||||
import os, sets, random, httpClient, json, strutils, strformat, options, deques, times
|
||||
import gintro/[gdkpixbuf, gobject]
|
||||
import common
|
||||
|
||||
@@ -53,8 +53,9 @@ proc newFileOpResult(file: string): FileOpResult =
|
||||
# Utilities
|
||||
########################
|
||||
|
||||
proc log(ip: ImageProvider, msg: string) =
|
||||
if ip.verbose: echo msg
|
||||
proc log(ip: ImageProvider, things: varargs[string, `$`]) =
|
||||
if ip.verbose:
|
||||
echo things.join()
|
||||
|
||||
########################
|
||||
# Image Provider procs
|
||||
@@ -147,7 +148,10 @@ proc next*(ip: var ImageProvider, width, height: int): FileOpResult =
|
||||
else:
|
||||
w = width
|
||||
h = ((rawPixbuf.height * w) / rawPixbuf.width).toInt
|
||||
var pixbuf = rawPixbuf.scaleSimple(w, h, InterpType.bilinear)
|
||||
let then = now()
|
||||
var pixbuf = rawPixbuf.scaleSimple(w, h, InterpType.nearest)
|
||||
let now = now()
|
||||
ip.log "Image scaled. Time: ", (now - then).inMilliseconds, "ms"
|
||||
# The pixbuf is written to disk and loaded again once because
|
||||
# directly setting the image from a pixbuf will leak memory
|
||||
let saved = pixbuf.savev(tmpFile, "png", @[])
|
||||
|
||||
@@ -48,10 +48,7 @@ router randopixRouter:
|
||||
|
||||
proc runServer*[ServerArgs](arg: ServerArgs) {.thread, nimcall.} =
|
||||
verbose = arg.verbose
|
||||
if verbose:
|
||||
logging.setLogFilter(lvlInfo)
|
||||
else:
|
||||
logging.setLogFilter(lvlNotice)
|
||||
logging.setLogFilter(lvlInfo)
|
||||
let port = Port(arg.port)
|
||||
let settings = newSettings(port=port)
|
||||
var server = initJester(randopixRouter, settings=settings)
|
||||
|
||||
Reference in New Issue
Block a user