mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
ImageViewer: Transform the image's dimension accordingly to the metadata
Exif metadata have two tags to store the pixel density along each axis. If both values are different and no action is taken, the resulting image will appear deformed. This commit scales the displayed bitmap accordingly to these tags in order to show the image in its intended shape. This unfortunately includes a lot of plumbing to get this information through IPC.
This commit is contained in:
parent
8dd887b3c8
commit
8e2102fb73
6 changed files with 27 additions and 8 deletions
|
@ -66,9 +66,9 @@ private:
|
|||
|
||||
class BitmapImage final : public Image {
|
||||
public:
|
||||
static NonnullRefPtr<BitmapImage> create(Gfx::Bitmap& bitmap) { return adopt_ref(*new BitmapImage(bitmap)); }
|
||||
static NonnullRefPtr<BitmapImage> create(Gfx::Bitmap& bitmap, Gfx::FloatPoint scale) { return adopt_ref(*new BitmapImage(bitmap, scale)); }
|
||||
|
||||
virtual Gfx::IntSize size() const override { return m_bitmap->size(); }
|
||||
virtual Gfx::IntSize size() const override { return { round(m_bitmap->size().width() * m_scale.x()), round(m_bitmap->size().height() * m_scale.y()) }; }
|
||||
|
||||
virtual void flip(Gfx::Orientation) override;
|
||||
virtual void rotate(Gfx::RotationDirection) override;
|
||||
|
@ -81,12 +81,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
BitmapImage(Gfx::Bitmap& bitmap)
|
||||
BitmapImage(Gfx::Bitmap& bitmap, Gfx::FloatPoint scale)
|
||||
: m_bitmap(bitmap)
|
||||
, m_scale(scale)
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<Gfx::Bitmap> m_bitmap;
|
||||
Gfx::FloatPoint m_scale;
|
||||
};
|
||||
|
||||
class ViewWidget final : public GUI::AbstractZoomPanWidget {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue