00001 #ifndef _HAVE_MBPIXBUF_H
00002 #define _HAVE_MBPIXBUF_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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 } MBPixbuf;
00151
00158 typedef struct MBPixbufImage
00159 {
00160 int width;
00161 int height;
00162 unsigned char *rgba;
00163 int has_alpha;
00164 XImage *ximg;
00166 } MBPixbufImage;
00167
00168
00169
00170
00171 #define mb_pixbuf_img_set_pixel(i, x, y, r, g, b) { \
00172 (i)->rgba[(((y)*(i)->width*4)+((x)*4))] = r; \
00173 (i)->rgba[(((y)*(i)->width*4)+((x)*4))+1] = g; \
00174 (i)->rgba[(((y)*(i)->width*4)+((x)*4))+2] = b; \
00175 (i)->rgba[(((y)*(i)->width*4)+((x)*4))+3] = 0; \
00176 }
00177
00183 #define mb_pixbuf_img_set_pixel_alpha(i, x, y, a) { \
00184 if ((i)->has_alpha) (i)->rgba[(((y)*(i)->width*4)+((x)*4))+3] = a; \
00185 }
00186
00192 #define mb_pixbuf_img_get_width(image) (image)->width
00193
00199 #define mb_pixbuf_img_get_height(image) (image)->height
00200
00206 #define mb_pixbuf_get_depth(pb) (pb)->depth
00207
00213 #define mb_pixbuf_img_has_alpha(image) (image)->has_alpha
00214
00222 MBPixbuf*
00223 mb_pixbuf_new (Display *display,
00224 int screen);
00225
00226
00236 MBPixbuf *
00237 mb_pixbuf_new_extended(Display *dpy,
00238 int scr,
00239 Visual *vis,
00240 int depth);
00241
00242
00247 MBPixbufImage*
00248 mb_pixbuf_img_new (MBPixbuf *pb,
00249 int width,
00250 int height);
00251
00260 MBPixbufImage *
00261 mb_pixbuf_img_rgba_new(MBPixbuf *pixbuf,
00262 int width,
00263 int height);
00264
00273 MBPixbufImage *
00274 mb_pixbuf_img_rgb_new (MBPixbuf *pixbuf,
00275 int width,
00276 int height);
00277
00281 MBPixbufImage *
00282 mb_pixbuf_img_new_from_drawable (MBPixbuf *pixbuf,
00283 Drawable drawable,
00284 Drawable mask,
00285 int source_x,
00286 int source_y,
00287 int source_w,
00288 int source_h);
00289
00304 MBPixbufImage *
00305 mb_pixbuf_img_new_from_x_drawable (MBPixbuf *pixbuf,
00306 Drawable drawable,
00307 Drawable mask,
00308 int source_x,
00309 int source_y,
00310 int source_w,
00311 int source_h,
00312 Bool want_alpha);
00313
00314
00323 MBPixbufImage *
00324 mb_pixbuf_img_new_from_file (MBPixbuf *pixbuf,
00325 const char *filename);
00326
00337 MBPixbufImage *
00338 mb_pixbuf_img_new_from_data(MBPixbuf *pixbuf,
00339 const unsigned char *data,
00340 int width,
00341 int height,
00342 Bool has_alpha);
00343
00344
00351 void
00352 mb_pixbuf_img_free (MBPixbuf *pixbuf,
00353 MBPixbufImage *image);
00354
00364 void mb_pixbuf_img_render_to_drawable (MBPixbuf *pixbuf,
00365 MBPixbufImage *image,
00366 Drawable drw,
00367 int drw_x,
00368 int drw_y);
00369
00381 void
00382 mb_pixbuf_img_render_to_drawable_with_gc(MBPixbuf *pb,
00383 MBPixbufImage *img,
00384 Drawable drw,
00385 int drw_x,
00386 int drw_y,
00387 GC gc);
00388
00389
00399 void mb_pixbuf_img_render_to_mask (MBPixbuf *pixbuf,
00400 MBPixbufImage *image,
00401 Drawable mask,
00402 int mask_x,
00403 int mask_y);
00404
00412 MBPixbufImage *mb_pixbuf_img_clone (MBPixbuf *pixbuf,
00413 MBPixbufImage *image);
00414
00425 void mb_pixbuf_img_fill (MBPixbuf *pixbuf,
00426 MBPixbufImage *image,
00427 int r,
00428 int g,
00429 int b,
00430 int a);
00431
00443 void
00444 mb_pixbuf_img_plot_pixel (MBPixbuf *pixbuf,
00445 MBPixbufImage *image,
00446 int x,
00447 int y,
00448 unsigned char r,
00449 unsigned char g,
00450 unsigned char b);
00451
00452
00465 void
00466 mb_pixbuf_img_get_pixel (MBPixbuf *pixbuf,
00467 MBPixbufImage *image,
00468 int x,
00469 int y,
00470 unsigned char *r,
00471 unsigned char *g,
00472 unsigned char *b,
00473 unsigned char *a
00474 );
00475
00483 unsigned char *
00484 mb_pixbuf_img_data (MBPixbuf *pixbuf,
00485 MBPixbufImage *image);
00486
00487
00488
00501 void
00502 mb_pixbuf_img_plot_pixel_with_alpha (MBPixbuf *pixbuf,
00503 MBPixbufImage *image,
00504 int x,
00505 int y,
00506 unsigned char r,
00507 unsigned char g,
00508 unsigned char b,
00509 unsigned char a);
00510
00525 void mb_pixbuf_img_copy (MBPixbuf *pixbuf,
00526 MBPixbufImage *dest,
00527 MBPixbufImage *src,
00528 int sx,
00529 int sy,
00530 int sw,
00531 int sh,
00532 int dx,
00533 int dy);
00534
00535
00549 void mb_pixbuf_img_copy_composite (MBPixbuf *pixbuf,
00550 MBPixbufImage *dest,
00551 MBPixbufImage *src,
00552 int sx,
00553 int sy,
00554 int sw,
00555 int sh,
00556 int dx,
00557 int dy);
00558
00573 void mb_pixbuf_img_copy_composite_with_alpha (MBPixbuf *pixbuf,
00574 MBPixbufImage *dest,
00575 MBPixbufImage *src,
00576 int sx, int sy,
00577 int sw, int sh,
00578 int dx, int dy,
00579 int overall_alpha );
00580
00585 void mb_pixbuf_img_composite (MBPixbuf *pb,
00586 MBPixbufImage *dest,
00587 MBPixbufImage *src,
00588 int dx,
00589 int dy);
00590
00600 MBPixbufImage *mb_pixbuf_img_scale (MBPixbuf *pixbuf,
00601 MBPixbufImage *image,
00602 int new_width,
00603 int new_height);
00604
00605
00606 MBPixbufImage *mb_pixbuf_img_scale_down (MBPixbuf *pixbuf,
00607 MBPixbufImage *image,
00608 int new_width,
00609 int new_height);
00610
00611
00612 MBPixbufImage *mb_pixbuf_img_scale_up (MBPixbuf *pixbuf,
00613 MBPixbufImage *image,
00614 int new_width,
00615 int new_height);
00616
00625 MBPixbufImage *
00626 mb_pixbuf_img_transform (MBPixbuf *pixbuf,
00627 MBPixbufImage *image,
00628 MBPixbufTransform transform);
00629
00630
00633 #ifdef __cplusplus
00634 }
00635 #endif
00636
00637
00638 #endif
00639
00640
00641