+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
#include "mag_image.h"
type = atoi((char*)&msg[1]);
switch (type){
case FACTOR :
- old_factor = data->factor;
- data->factor = get_num(msg);
- printf("FACTOR = %d\n",data->factor);
+ old_factor_x = data->factor_x;
+ data->factor_x = get_num(msg);
+ old_factor_y = data->factor_y;
+ data->factor_y = get_num(msg);
+ printf("FACTOR = %d\n",data->factor_x);
break;
case CONTRAST :
data->contrast = get_num(msg);
DisplayHeight(mag_data->target_display,screen_num),
0,
0,
- mag_data->factor,
- mag_data->factor,
+ mag_data->factor_x,
+ mag_data->factor_y,
GDK_INTERP_NEAREST);
gdk_pixbuf_render_to_drawable (scaled_image,
0,0,0,0,DisplayWidth (mag_data->target_display,screen_num),
DisplayHeight(mag_data->target_display,screen_num),
GDK_RGB_DITHER_NORMAL,0,0);
+
+ gdk_window_raise (drawing_area->window);
return TRUE;
}
Window root_return, child_return;
int win_x_return,win_y_return;
unsigned int mask_return;
- XQueryPointer(mag_data->source_display,image_root_window,
+ XQueryPointer(mag_data->source_display,spi_image_root_window,
&root_return,&child_return,
&mag_data->center.x,&mag_data->center.y,
&win_x_return,&win_y_return,&mask_return);
total_width = DisplayWidth (mag_data->source_display,screen_num);
total_height = DisplayHeight(mag_data->source_display,screen_num);
- x = mag_data->center.x - mag_data->mag_width/mag_data->factor/2;
- y = mag_data->center.y - mag_data->mag_height/mag_data->factor/2;
+ x = mag_data->center.x - mag_data->mag_width/mag_data->factor_x/2;
+ y = mag_data->center.y - mag_data->mag_height/mag_data->factor_y/2;
- if(mag_data->center.x < mag_data->mag_width/mag_data->factor/2)
+ if(mag_data->center.x < mag_data->mag_width/mag_data->factor_x/2)
x = 0;
- if(mag_data->center.x > (total_width - mag_data->mag_width/mag_data->factor/2))
- x = total_width - mag_data->mag_width/mag_data->factor;
- if(mag_data->center.y < mag_data->mag_height/mag_data->factor/2)
+ if(mag_data->center.x > (total_width - mag_data->mag_width/mag_data->factor_x/2))
+ x = total_width - mag_data->mag_width/mag_data->factor_x;
+ if(mag_data->center.y < mag_data->mag_height/mag_data->factor_y/2)
y = 0;
- if(mag_data->center.y > (total_height - mag_data->mag_height/mag_data->factor/2))
- y = total_height - mag_data->mag_height/mag_data->factor;
+ if(mag_data->center.y > (total_height - mag_data->mag_height/mag_data->factor_y/2))
+ y = total_height - mag_data->mag_height/mag_data->factor_y;
if(x < 0)
x = 0;
if(y < 0)
total_height,
total_width);
*/
- if(mag_data->factor != old_factor){
+ if(mag_data->factor_x != old_factor_x || mag_data->factor_y != old_factor_y){
g_object_unref((GObject *)image);
image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
- DisplayWidth (mag_data->target_display,screen_num)/mag_data->factor,
- DisplayHeight(mag_data->target_display,screen_num)/mag_data->factor);
+ DisplayWidth (mag_data->target_display,screen_num)/mag_data->factor_x,
+ DisplayHeight(mag_data->target_display,screen_num)/mag_data->factor_y);
/* yes, use target display above, since the size of the area grabbed depends on the target */
- old_factor = mag_data->factor;
+ old_factor_x = mag_data->factor_x;
+ old_factor_y = mag_data->factor_y;
}
- get_root_image(image_root_window,
+ get_root_image(spi_image_root_window,
image,
x,
y,
-/* Image grabbing and convertion routines from gdk-pixbuf-xlib */
+/* SpiImage grabbing and convertion routines from gdk-pixbuf-xlib */
/*
convert 1 bits-pixel data
no alpha
};
static void
-rgbconvert (XImage *image, guchar *pixels, int rowstride, int alpha, xlib_colormap *cmap)
+rgbconvert (XImage *image, guchar *pixels, int rowstride, int alpha, xlib_colormap *cmap,
+ MagnifierData *mag_data)
{
- int index = (image->byte_order == MSBFirst) | (alpha != 0) << 1;
- int bank=5; /* default fallback converter */
- Visual *v = cmap->visual;
-
+ int index = (image->byte_order == MSBFirst) | (alpha != 0) << 1;
+ int bank=5; /* default fallback converter */
+ Visual *v = cmap->visual;
+ if (mag_data->fast_rgb_convert)
+ {
switch (v->class) {
/* I assume this is right for static & greyscale's too? */
case StaticGray:
/* always use the slow version */
break;
}
+ }
if (bank==5) {
convert_real_slow(image, pixels, rowstride, cmap, alpha);
}
}
-
-
-void get_root_image(Window src,GdkPixbuf *dest, int src_x, int src_y, MagnifierData *mag_data) {
+void get_root_image(Window src, GdkPixbuf *dest, int src_x, int src_y, MagnifierData *mag_data) {
XImage *image;
- int width = mag_data->mag_width/mag_data->factor;
- int height = mag_data->mag_height/mag_data->factor;
+ int width = mag_data->mag_width/mag_data->factor_x;
+ int height = mag_data->mag_height/mag_data->factor_y;
- /* Get Image in ZPixmap format (packed bits). */
+ /* Get SpiImage in ZPixmap format (packed bits). */
image = XGetImage (mag_data->source_display, src, src_x, src_y,
width, height, AllPlanes, ZPixmap);
g_assert(image != NULL);
rgbconvert (image, gdk_pixbuf_get_pixels(dest),
gdk_pixbuf_get_rowstride(dest),
gdk_pixbuf_get_has_alpha(dest),
- x_cmap);
+ x_cmap,
+ mag_data);
+
+ /* would like to use GDK routine, but since we don't have multi-head
+ yet, we have to use X */
+
XDestroyImage (image);
}