~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-tools/tinatool/gphx/gdk2/gphxGdk_picture.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :  TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/gphx/gdk2/gphxGdk_picture.c,v $
 37  * Date    :  $Date: 2005/06/01 20:06:26 $
 38  * Version :  $Revision: 1.1 $
 39  * CVS Id  :  $Id: gphxGdk_picture.c,v 1.1 2005/06/01 20:06:26 paul Exp $
 40  *
 41  * Author  :  giob@man.ac.uk, paul.bromiley@manchester.ac.uk
 42  *
 43  *********
 44 */
 45 /** 
 46  *  @file  gphxGdk_picture.c
 47  *  @brief Get a GdkImage from a tv_screen and use as background and for format conversion.
 48  *
 49  *  DUMP FUNCTIONS STILL TO BE DONE. 
 50  *
 51  *  Note: the functions in this file are duplicated for each graphics lib (x11, GDK, etc ...).
 52  *
 53  */
 54 
 55 
 56 #include "gphxGdk_picture.h"
 57 
 58 #if HAVE_CONFIG_H
 59   #include <config.h>
 60 #endif
 61 
 62 #include <gtk/gtk.h>
 63 #include <tinatool/gphx/gdk2/gphx_GdkDef.h>
 64 
 65 
 66 /**
 67  * @brief  Get a GdkImage from the specified Tv_screen and store in a Tv_picture struct.  
 68  * @param  tv_screen   Pointer to the Tv_screen to be queried.
 69  * @return Tv_picture *   Pointer to a new Tv_picture struct containing the image.
 70  *
 71  * Note that this guy uses a different concept to the Xv Tina, in that it uses an image.
 72  * (i.e. GdkImage) instead of a Pixmap.  It does so because only limited functionality
 73  * is provided for GdkPixmaps.
 74  *
 75  * However a GdkImage is stored client side, so while manipulation is quick transfer to a 
 76  * window on the server side is slow (especially if they are on different machines).
 77  *
 78  * Note also the nasty error trap.  This is because enlarging windows can move parts of 
 79  * them offscreen, and when Gdk tries to read the offscreen pixels into the image it 
 80  * crashes horribly.  It would be better to detect when the window goes offscreen and 
 81  * prevent the error happening, but this works and there isn't really time just now to
 82  * fix it in a more satisfatory way.
 83  *
 84  * When the error trap is used, the image is not saved and the repaint function will not
 85  * work unless the user does a repaint.
 86  */
 87 /* Old version, updated to solve graphical corruption bug
 88 Tv_picture   *tv_screen_get_picture(Tv_screen *tv_screen)
 89 {
 90   GtkWidget  *widget;
 91   GdkDrawable *drawable;
 92   GdkPixmap *dest;
 93   GdkPixbuf *pbuf;
 94   GdkColormap *cmap;
 95   GdkGC *gc;
 96 
 97   Tv_picture *picture = ts_ralloc(Tv_picture);
 98 
 99   if (tv_screen != NULL)
100   {
101     gdk_error_trap_push();
102 
103     widget = GTK_WIDGET(tv_screen->canvas);
104     drawable = GDK_DRAWABLE(widget->window);
105     dest = gdk_pixmap_new(NULL, tv_screen->width, tv_screen->height, 24);
106     cmap = gdk_window_get_colormap(drawable);
107     pbuf = gdk_pixbuf_get_from_drawable(NULL, drawable, cmap, 0, 0, 0, 0, tv_screen->width, tv_screen->height);
108 
109     gc = gdk_gc_new(dest);
110     gdk_draw_pixbuf(dest, gc, pbuf, 0, 0, 0, 0, tv_screen->width, tv_screen->height, 0, 0, 0);
111 
112     g_object_unref(G_OBJECT(gc));
113     g_object_unref(G_OBJECT(pbuf));
114     gdk_flush(); 
115 
116     if (gdk_error_trap_pop())
117     {
118       format_flush("GDK error:  Can't get offscreen pixmap.\n"); 
119       format_flush("Window repaint will not work properly.\n"); 
120       picture->pixmap = NULL;
121     }
122     else
123     {
124       picture->pixmap = gdk_image_get(dest, 0, 0, tv_screen->width, tv_screen->height);
125       picture->tv_screen = tv_screen;
126     }
127   }
128 
129   return(picture);
130 }
131 */
132 /* New version */
133 Tv_picture   *tv_screen_get_picture(Tv_screen *tv_screen)
134 {
135   GtkWidget  *widget;
136   GdkDrawable *drawable;
137   GdkPixbuf *pbuf;
138   GdkColormap *cmap;
139 
140   Tv_picture *picture = ts_ralloc(Tv_picture);
141 
142   if (tv_screen != NULL)
143   {
144     widget = GTK_WIDGET(tv_screen->canvas);
145     drawable = GDK_DRAWABLE(widget->window);
146     cmap = gdk_window_get_colormap(drawable);
147     pbuf = gdk_pixbuf_get_from_drawable(NULL, drawable, cmap, 0, 0, 0, 0, tv_screen->width, tv_screen->height);
148 
149     if (pbuf==NULL)
150     {
151       format_flush("GDK error:  Can't get offscreen pixmap.\n"); 
152       format_flush("Window repaint will not work properly.\n"); 
153       picture->pbuf = NULL;
154     }
155     else
156     {
157       picture->pbuf = pbuf;
158       picture->tv_screen = tv_screen;
159     }
160   }
161 
162   return(picture);
163 }
164 
165 
166 /**
167  * @brief  Free up a Tv_picture struct (specified as a void pointer).  
168  * @param  pic   Void pointer to the Tv_picture to be freed.
169  */
170 void   picture_free(void *pic)
171 {
172   Tv_picture *picture = (Tv_picture *) pic;
173 
174   if ((picture != NULL) && (picture->pbuf != NULL))
175     g_object_unref(picture->pbuf);
176 
177   rfree((void *) pic);
178 }
179 
180 
181 /**
182  * @brief  .  
183  * @param  tv_screen   Pointer to the Tv_screen to be queried.
184  * @return .
185  *
186  * .
187  */
188 void    picture_write(FILE * fp, Tv_picture * picture)
189 {
190 }
191 
192 /**
193  * @brief  .  
194  * @param  tv_screen   Pointer to the Tv_screen to be queried.
195  * @return .
196  *
197  * .
198  */
199 Tv_picture *tv_screen_picture_read(Tv_screen * tv_screen, FILE * fp)
200 {
201         return(NULL);
202 }
203 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.