Panel zoom - improve output image resolution (#6709)

pull/6722/head
Galunid 4 years ago committed by GitHub
parent abfba6c709
commit b297fb7cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -414,9 +414,18 @@ function Document:getDrawnImagesStatistics()
end
function Document:getPagePart(pageno, rect, rotation)
local tile = self:renderPage(pageno, rect, 1, rotation, 1, 0)
local target = Blitbuffer.new(rect.w, rect.h, self.render_color and self.color_bb_type or nil)
target:blitFrom(tile.bb, 0, 0, rect.x, rect.y, rect.w, rect.h)
local canvas_size = CanvasContext:getSize()
local zoom = math.min(canvas_size.w*2 / rect.w, canvas_size.h*2 / rect.h)
-- it's really, really important to do math.floor, otherwise we get image projection
local scaled_rect = {
x = math.floor(rect.x * zoom),
y = math.floor(rect.y * zoom),
w = math.floor(rect.w * zoom),
h = math.floor(rect.h * zoom),
}
local tile = self:renderPage(pageno, scaled_rect, zoom, rotation, 1, 0)
local target = Blitbuffer.new(scaled_rect.w, scaled_rect.h, self.render_color and self.color_bb_type or nil)
target:blitFrom(tile.bb, 0, 0, scaled_rect.x, scaled_rect.y, scaled_rect.w, scaled_rect.h)
return target
end

Loading…
Cancel
Save