diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 14 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 51 |
2 files changed, 39 insertions, 26 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 215900275..e77e90de4 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1873,7 +1873,7 @@ set_title_settings(signal_user_data_t *ud, GhbValue *settings) if (!(keep_aspect || pic_par) || pic_par == 3) { ghb_dict_set_int(settings, "scale_height", - title->geometry.width - title->crop[0] - title->crop[1]); + title->geometry.height - title->crop[0] - title->crop[1]); } ghb_set_scale_settings(settings, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX); @@ -2501,7 +2501,7 @@ scale_width_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); ghb_clear_presets_selection(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, GHB_PIC_KEEP_WIDTH); + ghb_set_scale(ud, GHB_PIC_KEEP_WIDTH|GHB_PIC_KEEP_PAR); update_preview = TRUE; ghb_live_reset(ud); @@ -2516,7 +2516,7 @@ scale_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); ghb_clear_presets_selection(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, GHB_PIC_KEEP_HEIGHT); + ghb_set_scale(ud, GHB_PIC_KEEP_HEIGHT|GHB_PIC_KEEP_PAR); update_preview = TRUE; ghb_live_reset(ud); @@ -2532,7 +2532,7 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); ghb_clear_presets_selection(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, 0); + ghb_set_scale(ud, GHB_PIC_KEEP_PAR); update_preview = TRUE; ghb_live_reset(ud); @@ -2562,7 +2562,7 @@ display_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_clear_presets_selection(ud); ghb_live_reset(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, GHB_PIC_KEEP_DISPLAY_HEIGHT); + ghb_set_scale(ud, GHB_PIC_KEEP_DISPLAY_HEIGHT|GHB_PIC_KEEP_PAR); update_preview = TRUE; } @@ -2590,7 +2590,7 @@ scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_clear_presets_selection(ud); ghb_live_reset(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, 0); + ghb_set_scale(ud, GHB_PIC_KEEP_PAR); update_preview = TRUE; update_aspect_info(ud); @@ -2604,7 +2604,7 @@ show_crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); ghb_live_reset(ud); if (gtk_widget_is_sensitive(widget)) - ghb_set_scale(ud, 0); + ghb_set_scale(ud, GHB_PIC_KEEP_PAR); ghb_pref_save(ud->prefs, "preview_show_crop"); update_preview = TRUE; } diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index beb9797e5..88e7a89a1 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3746,6 +3746,8 @@ ghb_set_scale_settings(GhbValue *settings, gint mode) uiGeo.geometry.par.num = ghb_dict_get_int(settings, "PictureDisplayWidth"); uiGeo.geometry.par.den = width; + hb_reduce(&uiGeo.geometry.par.num, &uiGeo.geometry.par.den, + uiGeo.geometry.par.num, uiGeo.geometry.par.den); } } else @@ -3881,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"); @@ -4557,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"); @@ -4567,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; @@ -4579,14 +4590,16 @@ ghb_get_preview_image( // If the preview is too large to fit the screen, reduce it's size. if (ghb_dict_get_bool(ud->prefs, "reduce_hd_preview")) { - GdkScreen *ss; - gint s_w, s_h; gint factor = 80; if (ghb_dict_get_bool(ud->prefs, "preview_fullscreen")) { 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); @@ -4610,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; |