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
00230
MBPixbufImage*
00231
mb_pixbuf_img_new (MBPixbuf *pb,
00232
int width,
00233
int height);
00234
00243
MBPixbufImage *
00244
mb_pixbuf_img_rgba_new(MBPixbuf *pixbuf,
00245
int width,
00246
int height);
00247
00256
MBPixbufImage *
00257
mb_pixbuf_img_rgb_new (MBPixbuf *pixbuf,
00258
int width,
00259
int height);
00260
00264
MBPixbufImage *
00265
mb_pixbuf_img_new_from_drawable (MBPixbuf *pixbuf,
00266 Drawable drawable,
00267 Drawable mask,
00268
int source_x,
00269
int source_y,
00270
int source_w,
00271
int source_h);
00272
00287
MBPixbufImage *
00288
mb_pixbuf_img_new_from_x_drawable (MBPixbuf *pixbuf,
00289 Drawable drawable,
00290 Drawable mask,
00291
int source_x,
00292
int source_y,
00293
int source_w,
00294
int source_h,
00295 Bool want_alpha);
00296
00297
00306
MBPixbufImage *
00307
mb_pixbuf_img_new_from_file (MBPixbuf *pixbuf,
00308
const char *filename);
00309
00320
MBPixbufImage *
00321
mb_pixbuf_img_new_from_data(MBPixbuf *pixbuf,
00322
const unsigned char *data,
00323
int width,
00324
int height,
00325 Bool has_alpha);
00326
00327
00334
void
00335
mb_pixbuf_img_free (MBPixbuf *pixbuf,
00336 MBPixbufImage *image);
00337
00347
void mb_pixbuf_img_render_to_drawable (MBPixbuf *pixbuf,
00348 MBPixbufImage *image,
00349 Drawable drw,
00350
int drw_x,
00351
int drw_y);
00352
00362
void mb_pixbuf_img_render_to_mask (MBPixbuf *pixbuf,
00363 MBPixbufImage *image,
00364 Drawable mask,
00365
int mask_x,
00366
int mask_y);
00367
00375
MBPixbufImage *
mb_pixbuf_img_clone (MBPixbuf *pixbuf,
00376 MBPixbufImage *image);
00377
00388
void mb_pixbuf_img_fill (MBPixbuf *pixbuf,
00389 MBPixbufImage *image,
00390
int r,
00391
int g,
00392
int b,
00393
int a);
00394
00406
void
00407
mb_pixbuf_img_plot_pixel (MBPixbuf *pixbuf,
00408 MBPixbufImage *image,
00409
int x,
00410
int y,
00411
unsigned char r,
00412
unsigned char g,
00413
unsigned char b);
00414
00415
00428
void
00429
mb_pixbuf_img_get_pixel (MBPixbuf *pixbuf,
00430 MBPixbufImage *image,
00431
int x,
00432
int y,
00433
unsigned char *r,
00434
unsigned char *g,
00435
unsigned char *b,
00436
unsigned char *a
00437 );
00438
00446
unsigned char *
00447
mb_pixbuf_img_data (MBPixbuf *pixbuf,
00448 MBPixbufImage *image);
00449
00450
00451
00464
void
00465
mb_pixbuf_img_plot_pixel_with_alpha (MBPixbuf *pixbuf,
00466 MBPixbufImage *image,
00467
int x,
00468
int y,
00469
unsigned char r,
00470
unsigned char g,
00471
unsigned char b,
00472
unsigned char a);
00473
00488
void mb_pixbuf_img_copy (MBPixbuf *pixbuf,
00489 MBPixbufImage *dest,
00490 MBPixbufImage *src,
00491
int sx,
00492
int sy,
00493
int sw,
00494
int sh,
00495
int dx,
00496
int dy);
00497
00498
00512
void mb_pixbuf_img_copy_composite (MBPixbuf *pixbuf,
00513 MBPixbufImage *dest,
00514 MBPixbufImage *src,
00515
int sx,
00516
int sy,
00517
int sw,
00518
int sh,
00519
int dx,
00520
int dy);
00521
00536
void mb_pixbuf_img_copy_composite_with_alpha (MBPixbuf *pixbuf,
00537 MBPixbufImage *dest,
00538 MBPixbufImage *src,
00539
int sx,
int sy,
00540
int sw,
int sh,
00541
int dx,
int dy,
00542
int overall_alpha );
00543
00548
void mb_pixbuf_img_composite (MBPixbuf *pb,
00549 MBPixbufImage *dest,
00550 MBPixbufImage *src,
00551
int dx,
00552
int dy);
00553
00563
MBPixbufImage *
mb_pixbuf_img_scale (MBPixbuf *pixbuf,
00564 MBPixbufImage *image,
00565
int new_width,
00566
int new_height);
00567
00568
00569
MBPixbufImage *mb_pixbuf_img_scale_down (MBPixbuf *pixbuf,
00570 MBPixbufImage *image,
00571
int new_width,
00572
int new_height);
00573
00574
00575
MBPixbufImage *mb_pixbuf_img_scale_up (MBPixbuf *pixbuf,
00576 MBPixbufImage *image,
00577
int new_width,
00578
int new_height);
00579
00588
MBPixbufImage *
00589
mb_pixbuf_img_transform (MBPixbuf *pixbuf,
00590 MBPixbufImage *image,
00591 MBPixbufTransform transform);
00592
00593
00596
#ifdef __cplusplus
00597
}
00598
#endif
00599
00600
00601
#endif
00602
00603
00604