/*---------------------------------------------------------------------------- ** rgb_image.h ** ** **--------------------------------------------------------------------------- ** Copyright 2004 by CodeWeavers, Inc. ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program 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 General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** **--------------------------------------------------------------------------*/ #define SUCCESS 0 #define ERR_PNG_FILE 1 #define ERR_MALLOC 2 /*---------------------------------------------------------------------------- ** Structure to act as rgb holster **--------------------------------------------------------------------------*/ typedef struct _rgb { short r; short g; short b; } rgb; /*---------------------------------------------------------------------------- ** Structure to store image information in rgb format **--------------------------------------------------------------------------*/ typedef struct _rgb_image { rgb **data; int width; int height; int bit_depth; } rgb_image; /*---------------------------------------------------------------------------- ** Structure to record the pixel format for an ximage **--------------------------------------------------------------------------*/ typedef struct _pixel_format { unsigned long r_mask; unsigned long g_mask; unsigned long b_mask; int r_count; int g_count; int b_count; int r_shift; int g_shift; int b_shift; } pixel_format; /*---------------------------------------------------------------------------- ** Structure to store a window's image and misc information **--------------------------------------------------------------------------*/ typedef struct _win_image { XImage *ximage; pixel_format pformat; int origin_x; int origin_y; int width; int height; } win_image; /*---------------------------------------------------------------------------- ** Structure to store an rgb histogram **--------------------------------------------------------------------------*/ typedef struct _rgb_hist { double r[256]; double g[256]; double b[256]; int total_count; int width; int height; } rgb_hist; /*---------------------------------------------------------------------------- ** Function prototypes **--------------------------------------------------------------------------*/ int win_image_to_rgb_hist(win_image *w_image, rgb_hist *r_hist); int rgb_image_to_rgb_hist(rgb_image *r_image, rgb_hist *r_hist); rgb_hist* rgb_hist_init(); void rgb_hist_destroy(rgb_hist *var); void pixel_format_init(pixel_format *var); void win_image_destroy_ximage(win_image *var); void win_image_destroy(win_image *var); win_image* win_image_init(); void rgb_image_destroy_data(rgb_image *var); void rgb_image_destroy(rgb_image *var); rgb_image* rgb_image_init(); int rgb_image_malloc(rgb_image *image, int width, int height); int rgb_image_to_png(rgb_image *image, char *png_file); int png_to_rgb_image(char *png_file, rgb_image *image); void win_image_set_pixel_format(win_image *w_image); void find_viewable_coords(int global_coord, int dpy_dimension, int win_dimension, int *origin_coord, int *adjusted_dimension); void win_image_set_viewable_params(win_image *w_image, int global_x, int global_y, int display_width, int display_height, int win_width, int win_height); int win_image_set_ximage(win_image *wimage, Display *display, Window win); short convert_to_8bit(short pixel_component, int component_size); int win_image_to_rgb_image(win_image *w_image, rgb_image *r_image); int rgb_pixel_comparison(rgb *p1, rgb *p2, int err_margin); int rgb_image_subimage_search (rgb_image *image, rgb_image *subimage, int err_margin, int x, int y); int rgb_image_find_subimage(rgb_image *image, rgb_image *subimage, int err_margin, int *x, int *y); int rgb_image_attach(rgb_image **main_image, rgb_image **attach_image, int count);