summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/hb-backend.c77
1 files changed, 33 insertions, 44 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 25fb09ba1..88e7a89a1 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -3883,9 +3883,10 @@ get_preview_geometry(signal_user_data_t *ud, const hb_title_t *title,
srcGeo->par = title->geometry.par;
uiGeo->mode = ghb_settings_combo_int(ud->settings, "PicturePAR");
- uiGeo->keep = ghb_dict_get_bool(ud->settings, "PictureKeepRatio") ||
- uiGeo->mode == HB_ANAMORPHIC_STRICT ||
- uiGeo->mode == HB_ANAMORPHIC_LOOSE;
+ uiGeo->keep = (ghb_dict_get_bool(ud->settings, "PictureKeepRatio") ||
+ uiGeo->mode == HB_ANAMORPHIC_STRICT ||
+ uiGeo->mode == HB_ANAMORPHIC_LOOSE) ?
+ HB_KEEP_DISPLAY_ASPECT : 0;
uiGeo->itu_par = 0;
uiGeo->modulus = ghb_settings_combo_int(ud->settings, "PictureModulus");
uiGeo->crop[0] = ghb_dict_get_int(ud->settings, "PictureTopCrop");
@@ -4517,33 +4518,6 @@ ghb_get_preview_image(
uiGeo.geometry.par.num = 1;
uiGeo.geometry.par.den = 1;
- GdkScreen *ss;
- gint s_w, s_h;
-
- ss = gdk_screen_get_default();
- s_w = gdk_screen_get_width(ss);
- s_h = gdk_screen_get_height(ss);
-
- if (uiGeo.geometry.width > s_w * 2 ||
- uiGeo.geometry.height > s_h * 2)
- {
- double factor = 1.;
-
- // Image is of extreme size > twice the screen dimensions.
- // In some extreme cases (very lopsided PAR), this can cause
- // hb_get_preview2 to crash or hang.
- if (uiGeo.geometry.width > s_w)
- {
- factor = (double)s_w / uiGeo.geometry.width;
- }
- if (uiGeo.geometry.height * factor > s_h)
- {
- factor = (double)s_h / uiGeo.geometry.height;
- }
- uiGeo.geometry.width *= factor;
- uiGeo.geometry.height *= factor;
- }
-
GdkPixbuf *preview;
hb_image_t *image;
image = hb_get_preview2(h_scan, title->index, index, &uiGeo, deinterlace);
@@ -4586,9 +4560,11 @@ ghb_get_preview_image(
src_line += image->plane[0].stride;
dst += stride;
}
- gint w = ghb_dict_get_int(ud->settings, "scale_width");
- gint h = ghb_dict_get_int(ud->settings, "scale_height");
- ghb_par_scale(ud, &w, &h, resultGeo.par.num, resultGeo.par.den);
+
+ *out_width = ghb_dict_get_int(ud->settings, "scale_width");
+ *out_height = ghb_dict_get_int(ud->settings, "scale_height");
+ ghb_par_scale(ud, out_width, out_height,
+ resultGeo.par.num, resultGeo.par.den);
gint c0, c1, c2, c3;
c0 = ghb_dict_get_int(ud->settings, "PictureTopCrop");
@@ -4596,11 +4572,17 @@ ghb_get_preview_image(
c2 = ghb_dict_get_int(ud->settings, "PictureLeftCrop");
c3 = ghb_dict_get_int(ud->settings, "PictureRightCrop");
- gdouble xscale = (gdouble)w / (gdouble)(title->geometry.width - c2 - c3);
- gdouble yscale = (gdouble)h / (gdouble)(title->geometry.height - c0 - c1);
-
- *out_width = w;
- *out_height = h;
+ gdouble xscale, yscale;
+ if (ghb_dict_get_bool(ud->prefs, "preview_show_crop"))
+ {
+ xscale = (gdouble)image->width / title->geometry.width;
+ yscale = (gdouble)image->height / title->geometry.height;
+ }
+ else
+ {
+ xscale = (gdouble)image->width / (title->geometry.width - c2 - c3);
+ yscale = (gdouble)image->height / (title->geometry.height - c0 - c1);
+ }
int previewWidth = image->width;
int previewHeight = image->height;
@@ -4615,6 +4597,13 @@ ghb_get_preview_image(
factor = 100;
}
+ GdkScreen *ss;
+ gint s_w, s_h;
+
+ ss = gdk_screen_get_default();
+ s_w = gdk_screen_get_width(ss);
+ s_h = gdk_screen_get_height(ss);
+
if (previewWidth > s_w * factor / 100 ||
previewHeight > s_h * factor / 100)
{
@@ -4634,28 +4623,28 @@ ghb_get_preview_image(
}
xscale *= (gdouble)previewWidth / orig_w;
yscale *= (gdouble)previewHeight / orig_h;
- w *= (gdouble)previewWidth / orig_w;
- h *= (gdouble)previewHeight / orig_h;
scaled_preview = gdk_pixbuf_scale_simple(preview,
previewWidth, previewHeight, GDK_INTERP_HYPER);
g_object_unref(preview);
preview = scaled_preview;
}
}
+
if (ghb_dict_get_bool(ud->prefs, "preview_show_crop"))
{
c0 *= yscale;
c1 *= yscale;
c2 *= xscale;
c3 *= xscale;
+
// Top
- hash_pixbuf(preview, c2, 0, w, c0, 32, 0);
+ hash_pixbuf(preview, 0, 0, previewWidth, c0, 32, 0);
// Bottom
- hash_pixbuf(preview, c2, previewHeight-c1, w, c1, 32, 0);
+ hash_pixbuf(preview, 0, previewHeight-c1, previewWidth, c1, 32, 0);
// Left
- hash_pixbuf(preview, 0, c0, c2, h, 32, 1);
+ hash_pixbuf(preview, 0, 0, c2, previewHeight, 32, 1);
// Right
- hash_pixbuf(preview, previewWidth-c3, c0, c3, h, 32, 1);
+ hash_pixbuf(preview, previewWidth-c3, 0, c3, previewHeight, 32, 1);
}
hb_image_close(&image);
return preview;