type of source stereo image made adjustable from menu
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 19 Mar 2011 20:42:13 +0000 (21:42 +0100)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 27 Sep 2011 12:30:07 +0000 (14:30 +0200)
src/image-load.c
src/image.c
src/image.h
src/layout_image.c
src/layout_image.h
src/layout_util.c
src/pixbuf-renderer.c
src/pixbuf-renderer.h
src/renderer-tiles.c
src/typedefs.h

index e225dbe..e2cf7e0 100644 (file)
@@ -364,7 +364,7 @@ static void image_loader_sync_pixbuf(ImageLoader *il)
 
        if (g_ascii_strcasecmp(".jps", il->fd->extension) == 0)
                {
-               g_object_set_data(G_OBJECT(pb), "stereo_sbs", GINT_TO_POINTER(1));
+               g_object_set_data(G_OBJECT(pb), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
                }
 
        if (il->pixbuf) g_object_unref(il->pixbuf);
index 07d231a..b1a8c8b 100644 (file)
@@ -1124,6 +1124,11 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboo
                        }
                }
 
+       if (pixbuf && imd->user_stereo)
+               {
+               g_object_set_data(G_OBJECT(pixbuf), "stereo_data", GINT_TO_POINTER(imd->user_stereo));
+               }
+
        pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE);
        if (imd->cm)
                {
@@ -1443,6 +1448,17 @@ void image_stereo_swap(ImageWindow *imd)
        pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
 }
 
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd)
+{
+       return imd->user_stereo;
+}
+
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode)
+{
+       imd->user_stereo = stereo_mode;
+       image_reload(imd);
+}
+
 /* read ahead */
 
 void image_prebuffer_set(ImageWindow *imd, FileData *fd)
index 1c9e710..5c4837f 100644 (file)
@@ -96,6 +96,9 @@ gint image_stereo_get(ImageWindow *imd);
 void image_stereo_set(ImageWindow *imd, gint stereo_mode);
 void image_stereo_swap(ImageWindow *imd);
 
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd);
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode);
+
 /* read ahead, pass NULL to cancel */
 void image_prebuffer_set(ImageWindow *imd, FileData *fd);
 
index 9c9405b..e0b2e8c 100644 (file)
@@ -903,6 +903,7 @@ gboolean layout_image_get_desaturate(LayoutWindow *lw)
 }
 
 /* stereo */
+/*
 gint layout_image_stereo_get(LayoutWindow *lw)
 {
        if (!layout_valid(&lw)) return 0;
@@ -916,7 +917,7 @@ void layout_image_stereo_set(LayoutWindow *lw, gint stereo_mode)
 
        image_stereo_set(lw->image, stereo_mode);
 }
-
+*/
 void layout_image_stereo_swap(LayoutWindow *lw)
 {
        if (!layout_valid(&lw)) return;
@@ -924,6 +925,20 @@ void layout_image_stereo_swap(LayoutWindow *lw)
        image_stereo_swap(lw->image);
 }
 
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw)
+{
+       if (!layout_valid(&lw)) return 0;
+
+       return image_stereo_pixbuf_get(lw->image);
+}
+
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode)
+{
+       if (!layout_valid(&lw)) return;
+
+       image_stereo_pixbuf_set(lw->image, stereo_mode);
+}
+
 const gchar *layout_image_get_path(LayoutWindow *lw)
 {
        if (!layout_valid(&lw)) return NULL;
index aff9ef2..fe8efd1 100644 (file)
@@ -55,10 +55,15 @@ void layout_image_alter_orientation(LayoutWindow *lw, AlterType type);
 void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate);
 gboolean layout_image_get_desaturate(LayoutWindow *lw);
 
+/*
 gint layout_image_stereo_get(LayoutWindow *lw);
 void layout_image_stereo_set(LayoutWindow *lw, gint stereo_mode);
+*/
 void layout_image_stereo_swap(LayoutWindow *lw);
 
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw);
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode);
+
 void layout_image_next(LayoutWindow *lw);
 void layout_image_prev(LayoutWindow *lw);
 void layout_image_first(LayoutWindow *lw);
index d8b5503..bc2a1e9 100644 (file)
@@ -847,12 +847,9 @@ static void layout_menu_stereo_mode_cb(GtkRadioAction *action, GtkRadioAction *c
 {
        LayoutWindow *lw = data;
        gint mode = gtk_radio_action_get_current_value(action);
-       layout_image_stereo_set(lw, (layout_image_stereo_get(lw) & ~(PR_STEREO_ANAGLYPH | PR_STEREO_HORIZ | PR_STEREO_VERT)) | mode);
+       layout_image_stereo_pixbuf_set(lw, mode);
 }
 
-
-
-
 static void layout_menu_help_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
@@ -1433,10 +1430,10 @@ static GtkRadioActionEntry menu_histogram_mode[] = {
 };
 
 static GtkRadioActionEntry menu_stereo_mode_entries[] = {
-  { "StereoNone",      NULL,                   N_("_None"),                            NULL,                   N_("Stereo Off"),               PR_STEREO_NONE },
-  { "StereoAnaglyph",  NULL,                   N_("_Anaglyph"),                        NULL,                   N_("Stereo Anaglyph"),          PR_STEREO_ANAGLYPH },
-  { "StereoHoriz",     NULL,                   N_("_Side by Side"),                    NULL,                   N_("Stereo Side by Side"),      PR_STEREO_HORIZ },
-  { "StereoVert",      NULL,                   N_("Above-_Below"),                     NULL,                   N_("Stereo Above-Below"),       PR_STEREO_VERT }
+  { "StereoAuto",      NULL,                   N_("_Auto"),                            NULL,                   N_("Stereo Auto"),              STEREO_PIXBUF_DEFAULT },
+  { "StereoSBS",       NULL,                   N_("_Side by Side"),                    NULL,                   N_("Stereo Side by Side"),      STEREO_PIXBUF_SBS },
+  { "StereoCross",     NULL,                   N_("_Cross"),                           NULL,                   N_("Stereo Cross"),             STEREO_PIXBUF_CROSS },
+  { "StereoOff",       NULL,                   N_("_Off"),                             NULL,                   N_("Stereo Off"),               STEREO_PIXBUF_NONE }
 };
 
 
@@ -1580,10 +1577,10 @@ static const gchar *menu_ui_description =
 "      <menu action='StereoMenu'>"
 "        <menuitem action='StereoSwap'/>"
 "        <separator/>"
-"        <menuitem action='StereoNone'/>"
-"        <menuitem action='StereoAnaglyph'/>"
-"        <menuitem action='StereoHoriz'/>"
-"        <menuitem action='StereoVert'/>"
+"        <menuitem action='StereoAuto'/>"
+"        <menuitem action='StereoSBS'/>"
+"        <menuitem action='StereoCross'/>"
+"        <menuitem action='StereoOff'/>"
 "      </menu>"
 "      <menu action='ColorMenu'>"
 "        <menuitem action='UseColorProfiles'/>"
@@ -2411,6 +2408,9 @@ static void layout_util_sync_views(LayoutWindow *lw)
        action = gtk_action_group_get_action(lw->action_group, "ConnectZoomMenu");
        gtk_action_set_sensitive(action, lw->split_mode != SPLIT_NONE);
 
+       action = gtk_action_group_get_action(lw->action_group, "StereoAuto");
+       radio_action_set_current_value(GTK_RADIO_ACTION(action), layout_image_stereo_pixbuf_get(lw));
+
        layout_util_sync_color(lw);
 }
 
index 3f4b691..fb249f4 100644 (file)
@@ -2292,8 +2292,10 @@ void pr_create_anaglyph(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gin
  */
 static void pr_pixbuf_size_sync(PixbufRenderer *pr)
 {
-       pr->stereo_pixbuf_offset = 0;
+       pr->stereo_pixbuf_offset_left = 0;
+       pr->stereo_pixbuf_offset_right = 0;
        if (!pr->pixbuf) return;
+       gint stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_data"));
        switch (pr->orientation)
                {
                case EXIF_ORIENTATION_LEFT_TOP:
@@ -2302,20 +2304,30 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr)
                case EXIF_ORIENTATION_LEFT_BOTTOM:
                        pr->image_width = gdk_pixbuf_get_height(pr->pixbuf);
                        pr->image_height = gdk_pixbuf_get_width(pr->pixbuf);
-                       if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))
+                       if (stereo_data == STEREO_PIXBUF_SBS
                                {
                                pr->image_height /= 2;
-                               pr->stereo_pixbuf_offset = pr->image_height;
+                               pr->stereo_pixbuf_offset_right = pr->image_height;
+                               }
+                       else if (stereo_data == STEREO_PIXBUF_CROSS) 
+                               {
+                               pr->image_height /= 2;
+                               pr->stereo_pixbuf_offset_left = pr->image_height;
                                }
                        
                        break;
                default:
                        pr->image_width = gdk_pixbuf_get_width(pr->pixbuf);
                        pr->image_height = gdk_pixbuf_get_height(pr->pixbuf);
-                       if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))) 
+                       if (stereo_data == STEREO_PIXBUF_SBS) 
+                               {
+                               pr->image_width /= 2;
+                               pr->stereo_pixbuf_offset_right = pr->image_width;
+                               }
+                       else if (stereo_data == STEREO_PIXBUF_CROSS) 
                                {
                                pr->image_width /= 2;
-                               pr->stereo_pixbuf_offset = pr->image_width;
+                               pr->stereo_pixbuf_offset_left = pr->image_width;
                                }
                }
 }
index 90840a9..58db100 100644 (file)
@@ -101,7 +101,8 @@ struct _PixbufRenderer
 
        gint image_width;       /* image actual dimensions (pixels) */
        gint image_height;
-       gint stereo_pixbuf_offset; /* offset of the right part of the stereo image in pixbuf */
+       gint stereo_pixbuf_offset_right; /* offset of the right part of the stereo image in pixbuf */
+       gint stereo_pixbuf_offset_left; /* offset of the left part of the stereo image in pixbuf */
 
        GdkPixbuf *pixbuf;
 
index b6de2c9..c10d65f 100644 (file)
@@ -166,12 +166,12 @@ static gint rt_queue_draw_idle_cb(gpointer data);
 #define GET_RIGHT_PIXBUF_OFFSET(rt) \
         (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
          (!(rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset : 0 )
+          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
 
 #define GET_LEFT_PIXBUF_OFFSET(rt) \
         ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
          ( (rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset : 0 )
+          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
 
 
 static void rt_sync_scroll(RendererTiles *rt)
@@ -1405,7 +1405,8 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it,
                                   scale_x, scale_y,
                                   (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
                                   it->x + pb_x, it->y + pb_y);
-               if (rt->stereo_mode & PR_STEREO_ANAGLYPH && pr->stereo_pixbuf_offset > 0)
+               if (rt->stereo_mode & PR_STEREO_ANAGLYPH && 
+                   (pr->stereo_pixbuf_offset_right > 0 || pr->stereo_pixbuf_offset_left > 0))
                        {
                        GdkPixbuf *right_pb = rt_get_spare_tile(rt);
                        rt_tile_get_region(has_alpha,
index f7c59c6..a277b5d 100644 (file)
@@ -201,6 +201,12 @@ typedef enum {
        
 } PixbufRendererStereoMode;
 
+typedef enum {
+       STEREO_PIXBUF_DEFAULT  = 0,
+       STEREO_PIXBUF_SBS      = 1,
+       STEREO_PIXBUF_CROSS    = 2,
+       STEREO_PIXBUF_NONE     = 3
+} StereoPixbufData;
 
 #define MAX_SPLIT_IMAGES 4
 
@@ -456,6 +462,7 @@ struct _ImageWindow
        gboolean delay_flip;
        gint orientation;
        gboolean desaturate;
+       gint user_stereo;
 };
 
 #define FILEDATA_MARKS_SIZE 6