f-spot r3768 - in trunk: . src
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r3768 - in trunk: . src
- Date: Fri, 21 Mar 2008 04:27:17 +0000 (GMT)
Author: gburt
Date: Fri Mar 21 04:27:16 2008
New Revision: 3768
URL: http://svn.gnome.org/viewvc/f-spot?rev=3768&view=rev
Log:
2008-03-20 Gabriel Burt <gabriel burt gmail com>
* src/GlTransition.cs: Fix bug with slideshow mode that caused images
smaller than the screen size to be stretched to the size of the
screen. Fixes BNC #274021.
* src/MainWindow.cs: Get rid of duplicate code in Slideshow method;
call the Fullscreen method, and then Play ().
Modified:
trunk/ChangeLog
trunk/src/GlTransition.cs
trunk/src/MainWindow.cs
Modified: trunk/src/GlTransition.cs
==============================================================================
--- trunk/src/GlTransition.cs (original)
+++ trunk/src/GlTransition.cs Fri Mar 21 04:27:16 2008
@@ -46,7 +46,7 @@
System.Console.WriteLine ("GL_ARB_multitexture not supported");
return;
}
-
+
Gl.glViewport (0, 0, viewport.Width, viewport.Height);
Gl.glMatrixMode (Gl.GL_PROJECTION);
Gl.glLoadIdentity ();
@@ -132,7 +132,6 @@
Gl.glTranslatef (-viewport.Width *.5f, -viewport.Height * .5f, viewport.Width *.5f);
RenderPlane (viewport, next);
-
Gl.glRotatef (90, 0, 1, 0);
Gl.glTranslatef (0, 0, viewport.Width);
RenderPlane (viewport, previous);
@@ -309,20 +308,41 @@
protected static void Fit (Gdk.Rectangle viewport, Texture texture)
{
- float va = viewport.Width / (float) viewport.Height;
- float ta = texture.Width / (float) texture.Height;
+
+ float aspect_scale = (texture.Width / (float) texture.Height) / (viewport.Width / (float) viewport.Height);
+ float size_scale = Math.Max (viewport.Width / (float) texture.Width, viewport.Height / (float) texture.Height);
+ bool both_smaller = (viewport.Width / (float) texture.Width) > 1 && (viewport.Height / (float) texture.Height) > 1;
Gl.glMatrixMode (Gl.GL_TEXTURE);
Gl.glLoadIdentity ();
- if (ta < va) {
- Gl.glScalef (va/ta, 1, 0);
- Gl.glTranslatef (-(texture.Width / 2.0f - (texture.Width * ta/va) / 2.0f), 0, 0);
+
+ // If the image is smaller than the viewport, center it
+ if (both_smaller) {
+ Gl.glTranslatef (-0.5f * (viewport.Width - texture.Width), -0.5f * (viewport.Height - texture.Height), 0);
+ }
+
+ // Adjust for aspect ratio differences
+ if (aspect_scale == 1) {
+ // ignore
+ } else if (aspect_scale < 1) {
+ size_scale *= aspect_scale;
+ Gl.glScalef (1 / aspect_scale, 1, 0);
+ if (!both_smaller) {
+ Gl.glTranslatef (-0.5f * texture.Width * (1.0f - aspect_scale), 0, 0);
+ }
} else {
+ size_scale /= aspect_scale;
+ Gl.glScalef (1, aspect_scale, 0);
+ if (!both_smaller) {
+ Gl.glTranslatef (0, -0.5f * texture.Height * (1.0f - 1.0f/aspect_scale), 0);
+ }
+ }
- Gl.glScalef (1, ta/va, 0);
- Gl.glTranslatef (0, -(texture.Height / 2.0f - (texture.Height * va/ta) / 2.0f), 0);
+ // If the image is smaller than the viewport, ensure it's not stretched
+ if (both_smaller) {
+ Gl.glScalef (size_scale, size_scale, 0);
}
- }
+ }
protected void RenderPlane (Gdk.Rectangle viewport, Texture previous)
{
Modified: trunk/src/MainWindow.cs
==============================================================================
--- trunk/src/MainWindow.cs (original)
+++ trunk/src/MainWindow.cs Fri Mar 21 04:27:16 2008
@@ -2034,18 +2034,7 @@
void HandleViewSlideShow (object sender, EventArgs args)
{
- int active = Math.Max (ActiveIndex (), 0);
- if (fsview == null) {
- fsview = new FSpot.FullScreenView (query);
- fsview.Destroyed += HandleFullScreenViewDestroy;
- fsview.View.Item.Index = active;
- ColorDialog.SwitchViews (fsview.View);
- } else {
- // FIXME this needs to be another mode like PhotoView and IconView mode.
- fsview.View.Item.Index = active;
- }
-
- fsview.Show ();
+ HandleViewFullscreen (sender, args);
fsview.PlayPause ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]