diff options
author | Matthew Olsson <matthewcolsson@gmail.com> | 2022-03-29 21:27:17 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-04 14:59:37 +0200 |
commit | 3ecb41b7d9a2e5361ee5e6421d44dd1cbe944580 (patch) | |
tree | 8059fa41392eea6f189ba42372f4145d7041f91e /Userland/Libraries/LibPDF | |
parent | 091c2cfdca0d7a6df4d531ade763a4c4affeba6d (diff) | |
download | serenity-3ecb41b7d9a2e5361ee5e6421d44dd1cbe944580.zip |
PDFViewer: Support a continuous page view mode
Diffstat (limited to 'Userland/Libraries/LibPDF')
-rw-r--r-- | Userland/Libraries/LibPDF/Document.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibPDF/Renderer.cpp | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibPDF/Document.h b/Userland/Libraries/LibPDF/Document.h index 127577de11..d7836bb237 100644 --- a/Userland/Libraries/LibPDF/Document.h +++ b/Userland/Libraries/LibPDF/Document.h @@ -23,6 +23,9 @@ struct Rectangle { float lower_left_y; float upper_right_x; float upper_right_y; + + float width() const { return upper_right_x - lower_left_x; } + float height() const { return upper_right_y - lower_left_y; } }; struct Page { diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index 04f4fe5989..dbeff27279 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -38,8 +38,8 @@ Renderer::Renderer(RefPtr<Document> document, Page const& page, RefPtr<Gfx::Bitm Gfx::AffineTransform userspace_matrix; userspace_matrix.translate(media_box.lower_left_x, media_box.lower_left_y); - float width = media_box.upper_right_x - media_box.lower_left_x; - float height = media_box.upper_right_y - media_box.lower_left_y; + float width = media_box.width(); + float height = media_box.height(); float scale_x = static_cast<float>(bitmap->width()) / width; float scale_y = static_cast<float>(bitmap->height()) / height; userspace_matrix.scale(scale_x, scale_y); |