• Main Page
  • Modules
  • Files
  • File List

mbpixbuf.h

00001 #ifndef _HAVE_MBPIXBUF_H
00002 #define _HAVE_MBPIXBUF_H
00003 
00004 /* libmb
00005  * Copyright (C) 2002 Matthew Allum
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the
00019  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #include "libmb/mbconfig.h"
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <unistd.h>
00029 #include <signal.h>
00030 
00031 #ifdef USE_PNG
00032 #include <png.h>
00033 #endif
00034 
00035 #include <X11/Xlib.h>
00036 #include <X11/Xutil.h>
00037 #include <X11/Xatom.h>
00038 
00039 /* XXX if have_shm */
00040 
00041 #include <sys/ipc.h>
00042 #include <sys/shm.h>
00043 #include <sys/time.h>
00044 #include <X11/extensions/XShm.h>
00045 #include <X11/Xmd.h> 
00046 
00047 #ifdef USE_JPG
00048 #include "jpeglib.h"
00049 #endif
00050 
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00116 typedef enum
00117 {
00118   MBPIXBUF_TRANS_ROTATE_90,
00119   MBPIXBUF_TRANS_ROTATE_180,
00120   MBPIXBUF_TRANS_ROTATE_270,
00121   MBPIXBUF_TRANS_FLIP_VERT,
00122   MBPIXBUF_TRANS_FLIP_HORIZ
00123 } MBPixbufTransform;
00124 
00125 
00126 typedef struct _mb_pixbuf_col {
00127   int                 r, g, b;
00128   unsigned long       pixel;
00129 } MBPixbufColor;
00130 
00136 typedef struct MBPixbuf
00137 {
00138   Display       *dpy;
00139   int            scr;   
00140   Visual        *vis;
00141   Window         root;
00142   int            depth;
00143   Colormap       root_cmap;
00144   int            byte_order;
00145   int            num_of_cols;
00146   GC             gc;
00147   MBPixbufColor *palette;
00148   Bool           have_shm;
00149 
00150   int            internal_bytespp;
00151 
00152 } MBPixbuf;
00153 
00160 typedef struct MBPixbufImage 
00161 {
00162   int            width;     
00163   int            height;    
00164   unsigned char *rgba;      
00165   int            has_alpha; 
00166   XImage        *ximg;      
00168   int            internal_bytespp;
00169 
00170 } MBPixbufImage;
00171 
00172 /* macros */
00173 
00179 #define mb_pixbuf_img_set_pixel(i, x, y, r, g, b) { \
00180   (i)->rgba[(((y)*(i)->width*4)+((x)*4))]   = r;    \
00181   (i)->rgba[(((y)*(i)->width*4)+((x)*4))+1] = g;    \
00182   (i)->rgba[(((y)*(i)->width*4)+((x)*4))+2] = b;    \
00183   (i)->rgba[(((y)*(i)->width*4)+((x)*4))+3] = 0;    \
00184 }
00185 
00191 #define mb_pixbuf_img_set_pixel_alpha(i, x, y, a) { \
00192   if ((i)->has_alpha) (i)->rgba[(((y)*(i)->width*(i->internal_bytespp+1))+((x)*(i->internal_bytespp+1)))+i->internal_bytespp] = a;    \
00193 }
00194 
00195 
00196 
00202 #define mb_pixbuf_img_get_width(image)  (image)->width
00203 
00209 #define mb_pixbuf_img_get_height(image) (image)->height
00210 
00216 #define mb_pixbuf_get_depth(pb) (pb)->depth
00217 
00223 #define mb_pixbuf_img_has_alpha(image)  (image)->has_alpha
00224 
00232 MBPixbuf*
00233 mb_pixbuf_new (Display *display,
00234                int      screen);
00235 
00236 
00246 MBPixbuf *
00247 mb_pixbuf_new_extended(Display *dpy, 
00248                        int      scr, 
00249                        Visual  *vis,
00250                        int      depth);
00251 
00257 void
00258 mb_pixbuf_destroy(MBPixbuf *pixbuf);
00259 
00271 unsigned long
00272 mb_pixbuf_lookup_x_pixel(MBPixbuf *pixbuf, int r, int g, int b, int a);
00273 
00274 
00279 MBPixbufImage*
00280 mb_pixbuf_img_new (MBPixbuf  *pb,
00281                    int        width,
00282                    int        height);
00283 
00292 MBPixbufImage *
00293 mb_pixbuf_img_rgba_new(MBPixbuf *pixbuf, 
00294                        int       width, 
00295                        int       height);
00296 
00305 MBPixbufImage *
00306 mb_pixbuf_img_rgb_new (MBPixbuf *pixbuf, 
00307                        int       width, 
00308                        int       height);
00309 
00313 MBPixbufImage *
00314 mb_pixbuf_img_new_from_drawable (MBPixbuf *pixbuf,
00315                                  Drawable  drawable,
00316                                  Drawable  mask,
00317                                  int       source_x,
00318                                  int       source_y,
00319                                  int       source_w,
00320                                  int       source_h);
00321 
00336 MBPixbufImage *
00337 mb_pixbuf_img_new_from_x_drawable (MBPixbuf *pixbuf, 
00338                                    Drawable  drawable, 
00339                                    Drawable  mask,
00340                                    int       source_x, 
00341                                    int       source_y, 
00342                                    int       source_w, 
00343                                    int       source_h,
00344                                    Bool      want_alpha);
00345 
00346 
00355 MBPixbufImage *
00356 mb_pixbuf_img_new_from_file (MBPixbuf   *pixbuf,
00357                              const char *filename);
00358 
00369 MBPixbufImage *
00370 mb_pixbuf_img_new_from_data(MBPixbuf            *pixbuf, 
00371                             const unsigned char *data,
00372                             int                  width,
00373                             int                  height,
00374                             Bool                 has_alpha);
00375 
00376 
00387 MBPixbufImage *
00388 mb_pixbuf_img_new_from_int_data(MBPixbuf            *pixbuf, 
00389                                 const int           *data,
00390                                 int                  width,
00391                                 int                  height);
00392  
00399 void  
00400 mb_pixbuf_img_free (MBPixbuf      *pixbuf,
00401                     MBPixbufImage *image);
00402 
00412 void  mb_pixbuf_img_render_to_drawable (MBPixbuf      *pixbuf,
00413                                         MBPixbufImage *image,
00414                                         Drawable       drw,
00415                                         int            drw_x,
00416                                         int            drw_y);
00417 
00429 void
00430 mb_pixbuf_img_render_to_drawable_with_gc(MBPixbuf    *pixbuf,
00431                                          MBPixbufImage *image,
00432                                          Drawable     drw,
00433                                          int drw_x,
00434                                          int drw_y,
00435                                          GC gc);
00436 
00437 
00447 void mb_pixbuf_img_render_to_mask (MBPixbuf      *pixbuf,
00448                                    MBPixbufImage *image,
00449                                    Drawable       mask,
00450                                    int            mask_x,
00451                                    int            mask_y);
00452 
00460 MBPixbufImage *mb_pixbuf_img_clone (MBPixbuf      *pixbuf,
00461                                     MBPixbufImage *image);
00462 
00473 void
00474 mb_pixbuf_img_fill(MBPixbuf *pixbuf, 
00475                    MBPixbufImage *image,
00476                    int r, 
00477                    int g, 
00478                    int b, 
00479                    int a);
00480 
00493 void
00494 mb_pixbuf_img_plot_pixel (MBPixbuf      *pixbuf,
00495                           MBPixbufImage *image,
00496                           int            x,
00497                           int            y,
00498                           unsigned char  r,
00499                           unsigned char  g,
00500                           unsigned char  b);
00501 
00502 
00515 void
00516 mb_pixbuf_img_get_pixel (MBPixbuf      *pixbuf,
00517                          MBPixbufImage *image,
00518                          int            x,
00519                          int            y,
00520                          unsigned char *r,
00521                          unsigned char *g,
00522                          unsigned char *b,
00523                          unsigned char *a
00524                          );
00525 
00533 unsigned char *
00534 mb_pixbuf_img_data (MBPixbuf      *pixbuf,
00535                     MBPixbufImage *image);
00536 
00537 
00538 
00551 void
00552 mb_pixbuf_img_plot_pixel_with_alpha (MBPixbuf      *pixbuf,
00553                                      MBPixbufImage *image,
00554                                      int            x,
00555                                      int            y,
00556                                      unsigned char  r,
00557                                      unsigned char  g,
00558                                      unsigned char  b,
00559                                      unsigned char  a);
00560 
00575 void mb_pixbuf_img_copy (MBPixbuf      *pixbuf,
00576                          MBPixbufImage *dest,
00577                          MBPixbufImage *src,
00578                          int            sx,
00579                          int            sy,
00580                          int            sw,
00581                          int            sh,
00582                          int            dx,
00583                          int            dy);
00584 
00585 
00599 void mb_pixbuf_img_copy_composite (MBPixbuf      *pixbuf,
00600                                    MBPixbufImage *dest,
00601                                    MBPixbufImage *src,
00602                                    int            sx,
00603                                    int            sy,
00604                                    int            sw,
00605                                    int            sh,
00606                                    int            dx,
00607                                    int            dy);
00608 
00623 void mb_pixbuf_img_copy_composite_with_alpha (MBPixbuf      *pixbuf, 
00624                                               MBPixbufImage *dest,
00625                                               MBPixbufImage *src, 
00626                                               int sx, int sy, 
00627                                               int sw, int sh, 
00628                                               int dx, int dy,
00629                                               int overall_alpha );
00630 
00635 void mb_pixbuf_img_composite (MBPixbuf      *pb,
00636                               MBPixbufImage *dest,
00637                               MBPixbufImage *src,
00638                               int            dx,
00639                               int            dy);
00640 
00650 MBPixbufImage *mb_pixbuf_img_scale (MBPixbuf      *pixbuf,
00651                                     MBPixbufImage *image,
00652                                     int            new_width,
00653                                     int            new_height);
00654 
00655 
00656 MBPixbufImage *mb_pixbuf_img_scale_down (MBPixbuf      *pixbuf,
00657                                          MBPixbufImage *image,
00658                                          int            new_width,
00659                                          int            new_height);
00660 
00661 
00662 MBPixbufImage *mb_pixbuf_img_scale_up (MBPixbuf      *pixbuf,
00663                                        MBPixbufImage *image,
00664                                        int            new_width,
00665                                        int            new_height);
00666 
00675 MBPixbufImage *
00676 mb_pixbuf_img_transform (MBPixbuf          *pixbuf,
00677                          MBPixbufImage     *image,
00678                          MBPixbufTransform  transform);
00679 
00680 
00683 #ifdef __cplusplus
00684 }
00685 #endif
00686 
00687 
00688 #endif
00689 
00690 
00691 

Generated on Tue Sep 7 2010 10:22:44 for LibMB by  doxygen 1.7.1