diff --git a/libheif/box.h b/libheif/box.h index 8a510525fc..3fcc8e3da2 100644 --- a/libheif/box.h +++ b/libheif/box.h @@ -1059,16 +1059,16 @@ class Box_cmin : public FullBox principal_point_y -= clap->top(image_height); } - void apply_imir(const Box_imir* imir) { + void apply_imir(const Box_imir* imir, int image_width, int image_height) { switch (imir->get_mirror_direction()) { case heif_transform_mirror_direction_horizontal: focal_length_x *= -1; skew *= -1; - principal_point_x *= -1; + principal_point_x = image_width - 1 - principal_point_x; break; case heif_transform_mirror_direction_vertical: focal_length_y *= -1; - principal_point_y *= -1; + principal_point_y = image_height - 1 - principal_point_y; break; case heif_transform_mirror_direction_invalid: break; diff --git a/libheif/context.cc b/libheif/context.cc index 8ab3fa6330..3eadfa12d5 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -650,7 +650,7 @@ Error HeifContext::interpret_heif_file() auto imir = std::dynamic_pointer_cast(prop); if (imir) { - image->get_intrinsic_matrix().apply_imir(imir.get()); + image->get_intrinsic_matrix().apply_imir(imir.get(), image->get_width(), image->get_height()); } auto irot = std::dynamic_pointer_cast(prop);