Main Page | Modules | Directories | 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 
00260 
00265 MBPixbufImage*
00266 mb_pixbuf_img_new (MBPixbuf  *pb,
00267                    int        width,
00268                    int        height);
00269 
00278 MBPixbufImage *
00279 mb_pixbuf_img_rgba_new(MBPixbuf *pixbuf, 
00280                        int       width, 
00281                        int       height);
00282 
00291 MBPixbufImage *
00292 mb_pixbuf_img_rgb_new (MBPixbuf *pixbuf, 
00293                        int       width, 
00294                        int       height);
00295 
00299 MBPixbufImage *
00300 mb_pixbuf_img_new_from_drawable (MBPixbuf *pixbuf,
00301                                  Drawable  drawable,
00302                                  Drawable  mask,
00303                                  int       source_x,
00304                                  int       source_y,
00305                                  int       source_w,
00306                                  int       source_h);
00307 
00322 MBPixbufImage *
00323 mb_pixbuf_img_new_from_x_drawable (MBPixbuf *pixbuf, 
00324                                    Drawable  drawable, 
00325                                    Drawable  mask,
00326                                    int       source_x, 
00327                                    int       source_y, 
00328                                    int       source_w, 
00329                                    int       source_h,
00330                                    Bool      want_alpha);
00331 
00332 
00341 MBPixbufImage *
00342 mb_pixbuf_img_new_from_file (MBPixbuf   *pixbuf,
00343                              const char *filename);
00344 
00355 MBPixbufImage *
00356 mb_pixbuf_img_new_from_data(MBPixbuf            *pixbuf, 
00357                             const unsigned char *data,
00358                             int                  width,
00359                             int                  height,
00360                             Bool                 has_alpha);
00361 
00362 
00373 MBPixbufImage *
00374 mb_pixbuf_img_new_from_int_data(MBPixbuf            *pixbuf, 
00375                                 const int           *data,
00376                                 int                  width,
00377                                 int                  height);
00378  
00385 void  
00386 mb_pixbuf_img_free (MBPixbuf      *pixbuf,
00387                     MBPixbufImage *image);
00388 
00398 void  mb_pixbuf_img_render_to_drawable (MBPixbuf      *pixbuf,
00399                                         MBPixbufImage *image,
00400                                         Drawable       drw,
00401                                         int            drw_x,
00402                                         int            drw_y);
00403 
00415 void
00416 mb_pixbuf_img_render_to_drawable_with_gc(MBPixbuf    *pixbuf,
00417                                          MBPixbufImage *image,
00418                                          Drawable     drw,
00419                                          int drw_x,
00420                                          int drw_y,
00421                                          GC gc);
00422 
00423 
00433 void mb_pixbuf_img_render_to_mask (MBPixbuf      *pixbuf,
00434                                    MBPixbufImage *image,
00435                                    Drawable       mask,
00436                                    int            mask_x,
00437                                    int            mask_y);
00438 
00446 MBPixbufImage *mb_pixbuf_img_clone (MBPixbuf      *pixbuf,
00447                                     MBPixbufImage *image);
00448 
00459 void
00460 mb_pixbuf_img_fill(MBPixbuf *pixbuf, 
00461                    MBPixbufImage *image,
00462                    int r, 
00463                    int g, 
00464                    int b, 
00465                    int a);
00466 
00478 void
00479 mb_pixbuf_img_plot_pixel (MBPixbuf      *pixbuf,
00480                           MBPixbufImage *image,
00481                           int            x,
00482                           int            y,
00483                           unsigned char  r,
00484                           unsigned char  g,
00485                           unsigned char  b);
00486 
00487 
00500 void
00501 mb_pixbuf_img_get_pixel (MBPixbuf      *pixbuf,
00502                          MBPixbufImage *image,
00503                          int            x,
00504                          int            y,
00505                          unsigned char *r,
00506                          unsigned char *g,
00507                          unsigned char *b,
00508                          unsigned char *a
00509                          );
00510 
00518 unsigned char *
00519 mb_pixbuf_img_data (MBPixbuf      *pixbuf,
00520                     MBPixbufImage *image);
00521 
00522 
00523 
00536 void
00537 mb_pixbuf_img_plot_pixel_with_alpha (MBPixbuf      *pixbuf,
00538                                      MBPixbufImage *image,
00539                                      int            x,
00540                                      int            y,
00541                                      unsigned char  r,
00542                                      unsigned char  g,
00543                                      unsigned char  b,
00544                                      unsigned char  a);
00545 
00560 void mb_pixbuf_img_copy (MBPixbuf      *pixbuf,
00561                          MBPixbufImage *dest,
00562                          MBPixbufImage *src,
00563                          int            sx,
00564                          int            sy,
00565                          int            sw,
00566                          int            sh,
00567                          int            dx,
00568                          int            dy);
00569 
00570 
00584 void mb_pixbuf_img_copy_composite (MBPixbuf      *pixbuf,
00585                                    MBPixbufImage *dest,
00586                                    MBPixbufImage *src,
00587                                    int            sx,
00588                                    int            sy,
00589                                    int            sw,
00590                                    int            sh,
00591                                    int            dx,
00592                                    int            dy);
00593 
00608 void mb_pixbuf_img_copy_composite_with_alpha (MBPixbuf      *pixbuf, 
00609                                               MBPixbufImage *dest,
00610                                               MBPixbufImage *src, 
00611                                               int sx, int sy, 
00612                                               int sw, int sh, 
00613                                               int dx, int dy,
00614                                               int overall_alpha );
00615 
00620 void mb_pixbuf_img_composite (MBPixbuf      *pb,
00621                               MBPixbufImage *dest,
00622                               MBPixbufImage *src,
00623                               int            dx,
00624                               int            dy);
00625 
00635 MBPixbufImage *mb_pixbuf_img_scale (MBPixbuf      *pixbuf,
00636                                     MBPixbufImage *image,
00637                                     int            new_width,
00638                                     int            new_height);
00639 
00640 
00641 MBPixbufImage *mb_pixbuf_img_scale_down (MBPixbuf      *pixbuf,
00642                                          MBPixbufImage *image,
00643                                          int            new_width,
00644                                          int            new_height);
00645 
00646 
00647 MBPixbufImage *mb_pixbuf_img_scale_up (MBPixbuf      *pixbuf,
00648                                        MBPixbufImage *image,
00649                                        int            new_width,
00650                                        int            new_height);
00651 
00660 MBPixbufImage *
00661 mb_pixbuf_img_transform (MBPixbuf          *pixbuf,
00662                          MBPixbufImage     *image,
00663                          MBPixbufTransform  transform);
00664 
00665 
00668 #ifdef __cplusplus
00669 }
00670 #endif
00671 
00672 
00673 #endif
00674 
00675 
00676 

Generated on Tue Jan 11 08:51:10 2005 for LibMB by  doxygen 1.4.0