mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibPDF/PDFViewer: Support rotated pages
This commit is contained in:
parent
fbe712e265
commit
d5f94aaa7b
Notes:
sideshowbarker
2024-07-18 17:50:55 +09:00
Author: https://github.com/mattco98
Commit: d5f94aaa7b
Pull-request: https://github.com/SerenityOS/serenity/pull/7018
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/bcoles
Reviewed-by: https://github.com/tomuta
3 changed files with 22 additions and 3 deletions
|
@ -87,5 +87,16 @@ RefPtr<Gfx::Bitmap> PDFViewer::render_page(const PDF::Page& page)
|
|||
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { width, height });
|
||||
|
||||
PDF::Renderer::render(*m_document, page, bitmap);
|
||||
|
||||
if (page.rotate != 0) {
|
||||
int rotation_count = (page.rotate / 90) % 4;
|
||||
if (rotation_count == 3) {
|
||||
bitmap = bitmap->rotated(Gfx::RotationDirection::CounterClockwise);
|
||||
} else {
|
||||
for (int i = 0; i < rotation_count; i++)
|
||||
bitmap = bitmap->rotated(Gfx::RotationDirection::Clockwise);
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue