@@ -1205,24 +1205,24 @@ PDFErrorOr<Renderer::LoadedImage> Renderer::load_image(NonnullRefPtr<StreamObjec
1205
1205
return LoadedImage { bitmap, is_image_mask };
1206
1206
}
1207
1207
1208
- Gfx::AffineTransform Renderer::calculate_image_space_transformation (int width, int height )
1208
+ Gfx::AffineTransform Renderer::calculate_image_space_transformation (Gfx::IntSize size )
1209
1209
{
1210
1210
// Image space maps to a 1x1 unit of user space and starts at the top-left
1211
1211
auto image_space = state ().ctm ;
1212
1212
image_space.multiply (Gfx::AffineTransform (
1213
- 1 .0f / width,
1213
+ 1 .0f / size. width () ,
1214
1214
0 .0f ,
1215
1215
0 .0f ,
1216
- -1 .0f / height,
1216
+ -1 .0f / size. height () ,
1217
1217
0 .0f ,
1218
1218
1 .0f ));
1219
1219
return image_space;
1220
1220
}
1221
1221
1222
- void Renderer::show_empty_image (int width, int height )
1222
+ void Renderer::show_empty_image (Gfx::IntSize size )
1223
1223
{
1224
- auto image_space_transformation = calculate_image_space_transformation (width, height );
1225
- auto image_border = image_space_transformation.map (Gfx::IntRect { 0 , 0 , width, height });
1224
+ auto image_space_transformation = calculate_image_space_transformation (size );
1225
+ auto image_border = image_space_transformation.map (Gfx::IntRect { {}, size });
1226
1226
m_painter.stroke_path (rect_path (image_border), Color::Black, 1 );
1227
1227
}
1228
1228
@@ -1247,15 +1247,15 @@ static ErrorOr<void> apply_alpha_channel(NonnullRefPtr<Gfx::Bitmap> image_bitmap
1247
1247
PDFErrorOr<void > Renderer::show_image (NonnullRefPtr<StreamObject> image)
1248
1248
{
1249
1249
auto image_dict = image->dict ();
1250
- auto width = TRY (m_document->resolve_to <int >(image_dict->get_value (CommonNames::Width)));
1251
- auto height = TRY (m_document->resolve_to <int >(image_dict->get_value (CommonNames::Height)));
1252
1250
1253
1251
OwnPtr<ClipRAII> clip_raii;
1254
1252
if (m_rendering_preferences.clip_images )
1255
1253
clip_raii = make<ClipRAII>(*this );
1256
1254
1257
1255
if (!m_rendering_preferences.show_images ) {
1258
- show_empty_image (width, height);
1256
+ auto width = TRY (m_document->resolve_to <int >(image_dict->get_value (CommonNames::Width)));
1257
+ auto height = TRY (m_document->resolve_to <int >(image_dict->get_value (CommonNames::Height)));
1258
+ show_empty_image ({ width, height });
1259
1259
return {};
1260
1260
}
1261
1261
auto image_bitmap = TRY (load_image (image));
@@ -1285,8 +1285,8 @@ PDFErrorOr<void> Renderer::show_image(NonnullRefPtr<StreamObject> image)
1285
1285
}
1286
1286
}
1287
1287
1288
- auto image_space = calculate_image_space_transformation (width, height );
1289
- auto image_rect = Gfx::FloatRect { 0 , 0 , width, height };
1288
+ auto image_space = calculate_image_space_transformation (image_bitmap. bitmap -> size () );
1289
+ auto image_rect = Gfx::FloatRect { image_bitmap. bitmap -> rect () };
1290
1290
m_painter.draw_scaled_bitmap_with_transform (image_bitmap.bitmap ->rect (), image_bitmap.bitmap , image_rect, image_space);
1291
1291
return {};
1292
1292
}
0 commit comments