[snappy] ui: scale down videos bigger than screen resolution
- From: Luis de Bethencourt <luisbg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [snappy] ui: scale down videos bigger than screen resolution
- Date: Wed, 27 Mar 2013 22:29:35 +0000 (UTC)
commit 89cba6e09218d02333c81e9b3265860ccce909f6
Author: Luis de Bethencourt <luis debethencourt com>
Date: Wed Mar 27 18:29:29 2013 -0400
ui: scale down videos bigger than screen resolution
src/user_interface.c | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/user_interface.c b/src/user_interface.c
index ebf3bed..d4f23de 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -1230,6 +1230,8 @@ interface_start (UserInterface * ui, gchar * uri)
{
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 };
GtkSettings *gtk_settings;
+ GdkScreen *screen;
+ gint screen_width, screen_height;
g_print ("Loading ui!\n");
@@ -1242,8 +1244,31 @@ interface_start (UserInterface * ui, gchar * uri)
ui->media_width = ui->engine->media_width;
ui->media_height = ui->engine->media_height;
- ui->stage_width = ui->media_width;
- ui->stage_height = ui->media_height;
+ // Get screen size
+ screen = gdk_screen_get_default();
+ screen_width = gdk_screen_get_width(screen);
+ screen_height = gdk_screen_get_height(screen);
+
+ if (ui->media_width < screen_width && ui->media_height < screen_height) {
+ ui->stage_width = ui->media_width;
+ ui->stage_height = ui->media_height;
+
+ } else {
+ // Media bigger than the screen
+ gfloat aspect_ratio;
+
+ aspect_ratio = (float) ui->media_width / ui->media_height;
+ // Scale down to screen width proportionally
+ ui->stage_width = screen_width;
+ ui->stage_height = screen_width / aspect_ratio;
+
+ if (ui->stage_height > screen_height) {
+ // Stage height still too big, scale down to screen height
+ ui->stage_width = screen_height * aspect_ratio;
+ ui->stage_height = screen_height;
+ }
+ }
+
} else {
ui->filename = "";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]