~ubuntu-branches/ubuntu/lucid/sawfish/lucid-updates

« back to all changes in this revision

Viewing changes to src/images.c

  • Committer: Bazaar Package Importer
  • Author(s): Luis Rodrigo Gallardo Cruz
  • Date: 2009-03-05 11:53:27 UTC
  • mfrom: (1.2.8 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090305115327-1r4yg4eeodiyzu6z
Tags: 1:1.3.4-1
* New upstream release (Closes: #501092).
 - Includes patch from upstream BTS to fix focus handling after move-window-*
 (Closes: #132236).
 - Bump build dependency on GTK+ to 2.6.
* Loosen quilt dependency.
* Add README.source. Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* images.c -- Image handling
2
 
   $Id: images.c 4161 2005-01-04 15:34:25Z jsh $
 
2
   $Id: images.c 4244 2008-08-04 14:42:49Z jkozicki $
3
3
 
4
4
   Copyright (C) 1999, 2000 John Harper <john@dcs.warwick.ac.uk>
5
5
 
179
179
    {
180
180
        Pixmap bitmap;
181
181
        int ret = XReadBitmapFile (dpy, root_window, rep_STR(file),
182
 
                                   widthp, heightp, &bitmap, x_hotp, y_hotp);
 
182
                                   (gpointer) widthp, (gpointer) heightp, &bitmap, x_hotp, y_hotp);
183
183
 
184
184
        if (delete)
185
185
            Fdelete_file (file);
235
235
   if (rep_INTP (mask_id))
236
236
       mask = rep_INT (mask_id);
237
237
 
238
 
   if (!XGetGeometry (dpy, d, &root, &x, &y, &w, &h, &bdr, &dp))
 
238
   if (!XGetGeometry (dpy, d, &root, &x, &y, (gpointer) &w, (gpointer) &h, (gpointer) &bdr, (gpointer) &dp))
239
239
       return Qnil;
240
240
 
241
241
#if defined HAVE_IMLIB
247
247
       XImage *xim = XGetImage (dpy, mask, 0, 0, w, h, AllPlanes, ZPixmap);
248
248
       if (xim != 0)
249
249
       {
250
 
           u_char *pixels = im->rgb_data;
 
250
           unsigned char *pixels = im->rgb_data;
251
251
           int x, y;
252
252
           ImlibColor shape;
253
253
 
259
259
           {
260
260
               for (x = 0; x < w; x++)
261
261
               {
262
 
                   u_long pixel = XGetPixel (xim, x, y);
263
 
                   u_char *rgb = pixels + ((y * w) + x) * 3;
 
262
                   unsigned long pixel = XGetPixel (xim, x, y);
 
263
                   unsigned char *rgb = pixels + ((y * w) + x) * 3;
264
264
                   if (pixel != 0 && rgb[0] == shape.r
265
265
                       && rgb[1] == shape.g && rgb[2] == shape.b)
266
266
                   {
287
287
               {
288
288
                   if (XGetPixel (xim, x, y) == 0)
289
289
                   {
290
 
                       u_char *rgb = pixels + ((y * w) + x) * 3;
 
290
                       unsigned char *rgb = pixels + ((y * w) + x) * 3;
291
291
                       rgb[0] = shape.r;
292
292
                       rgb[1] = shape.g;
293
293
                       rgb[2] = shape.b;
309
309
       if (xim != 0)
310
310
       {
311
311
           int rowstride = gdk_pixbuf_get_rowstride (im);
312
 
           u_char *pixels = gdk_pixbuf_get_pixels (im);
 
312
           unsigned char *pixels = gdk_pixbuf_get_pixels (im);
313
313
           int x, y;
314
314
           for (y = 0; y < h; y++)
315
315
           {
316
316
               for (x = 0; x < w; x++)
317
317
               {
318
318
                   int idx = y * rowstride + x * 3;
319
 
                   u_char chan = (XGetPixel (xim, x, y) != 0) ? 0 : 255;
 
319
                   unsigned char chan = (XGetPixel (xim, x, y) != 0) ? 0 : 255;
320
320
                   pixels[idx+0] = chan;
321
321
                   pixels[idx+1] = chan;
322
322
                   pixels[idx+2] = chan;
400
400
    Imlib_flip_image_horizontal (imlib_id, VIMAGE(image)->image);
401
401
#else
402
402
    {
403
 
        u_char *pixels = image_pixels (VIMAGE (image));
 
403
        unsigned char *pixels = image_pixels (VIMAGE (image));
404
404
        int channels = image_channels (VIMAGE (image));
405
405
        int stride = image_row_stride (VIMAGE (image));
406
406
        int width = image_width (VIMAGE (image));
407
407
        int height = image_height (VIMAGE (image));
408
 
        u_char *buf = alloca (channels);
 
408
        unsigned char *buf = alloca (channels);
409
409
        int y;
410
410
        for (y = 0; y < height; y++)
411
411
        {
412
 
            u_char *left = pixels + y * stride;
413
 
            u_char *right = left + channels * (width - 1);
 
412
            unsigned char *left = pixels + y * stride;
 
413
            unsigned char *right = left + channels * (width - 1);
414
414
            while (left < right)
415
415
            {
416
416
                memcpy (buf, left, channels);
439
439
    Imlib_flip_image_vertical (imlib_id, VIMAGE(image)->image);
440
440
#else
441
441
    {
442
 
        u_char *pixels = image_pixels (VIMAGE (image));
 
442
        unsigned char *pixels = image_pixels (VIMAGE (image));
443
443
        int stride = image_row_stride (VIMAGE (image));
444
444
        int height = image_height (VIMAGE (image));
445
 
        u_char *buf = alloca (stride);
446
 
        u_char *top = pixels, *bottom = pixels + (height - 1) * stride;
 
445
        unsigned char *buf = alloca (stride);
 
446
        unsigned char *top = pixels, *bottom = pixels + (height - 1) * stride;
447
447
        while (top < bottom)
448
448
        {
449
449
            memcpy (buf, top, stride);
478
478
        int in_stride = gdk_pixbuf_get_rowstride (in);
479
479
        int in_width = gdk_pixbuf_get_width (in);
480
480
        int in_height = gdk_pixbuf_get_height (in);
481
 
        u_char *in_pixels = gdk_pixbuf_get_pixels (in);
 
481
        unsigned char *in_pixels = gdk_pixbuf_get_pixels (in);
482
482
        GdkPixbuf *out = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (in),
483
483
                                         gdk_pixbuf_get_has_alpha (in),
484
484
                                         gdk_pixbuf_get_bits_per_sample (in),
485
485
                                         in_height, in_width);
486
486
        int out_stride = gdk_pixbuf_get_rowstride (out);
487
 
        u_char *out_pixels = gdk_pixbuf_get_pixels (out);
 
487
        unsigned char *out_pixels = gdk_pixbuf_get_pixels (out);
488
488
        int x, y;
489
489
        for (y = 0; y < in_height; y++)
490
490
        {
745
745
}
746
746
 
747
747
static inline void
748
 
bevel_pixel (u_char *data, bool up, int bevel_percent)
 
748
bevel_pixel (unsigned char *data, bool up, int bevel_percent)
749
749
{
750
750
    unsigned int t0 = data[0], t1 = data[1], t2 = data[2];
751
751
    if (up)
763
763
}
764
764
 
765
765
static inline void
766
 
bevel_region (u_char *data, int row_stride, int bpp,
 
766
bevel_region (unsigned char *data, int row_stride, int bpp,
767
767
              int rx, int ry, int rw, int rh, bool up, int bevel_percent)
768
768
{
769
769
    int x, y;
770
770
    for (y = ry; y < ry + rh; y++)
771
771
    {
772
 
        u_char *row = data + y * row_stride + rx * bpp;
 
772
        unsigned char *row = data + y * row_stride + rx * bpp;
773
773
        for (x = rx; x < rx + rh; x++)
774
774
        {
775
775
            bevel_pixel (row, up, bevel_percent);
779
779
}
780
780
 
781
781
static inline void
782
 
bevel_horizontally (u_char *data, int width, int height,
 
782
bevel_horizontally (unsigned char *data, int width, int height,
783
783
                    int row_stride, int channels, 
784
784
                    int border, bool top, bool up, int bevel_percent)
785
785
{
787
787
    up = top ? up : !up;
788
788
    for (rows = 0; rows < border; rows++)
789
789
    {
790
 
        u_char *ptr = data;
 
790
        unsigned char *ptr = data;
791
791
        int x;
792
792
        if (top)
793
793
            ptr += (rows * row_stride) + (rows + 1) * channels;
802
802
}
803
803
 
804
804
static inline void
805
 
bevel_vertically (u_char *data, int width, int height,
 
805
bevel_vertically (unsigned char *data, int width, int height,
806
806
                  int row_stride, int channels,
807
807
                  int border, bool top, bool up, int bevel_percent)
808
808
{
810
810
    up = top ? up : !up;
811
811
    for (cols = 0; cols < border; cols++)
812
812
    {
813
 
        u_char *ptr = data;
 
813
        unsigned char *ptr = data;
814
814
        int y;
815
815
        if (top)
816
816
            ptr += cols * channels + (cols * row_stride);
888
888
{
889
889
    int width, height, stride, channels;
890
890
    int x, y, r, g, b;
891
 
    u_char *data;
 
891
    unsigned char *data;
892
892
 
893
893
    rep_DECLARE1(image, IMAGEP);
894
894
    if (COLORP(color))
936
936
defines the color of its pixels.
937
937
::end:: */
938
938
{
939
 
    u_char *data;
 
939
    unsigned char *data;
940
940
    int r, g, b;
941
941
    rep_DECLARE1(width, rep_INTP);
942
942
    rep_DECLARE2(height, rep_INTP);
998
998
    image_t src_im, dst_im;
999
999
    int src_width, src_height;
1000
1000
    int dst_width, dst_height;
1001
 
    int x, src_y, dst_y;
 
1001
    int x,dst_y;
1002
1002
 
1003
1003
    rep_DECLARE1(dst, IMAGEP);
1004
1004
    rep_DECLARE2(src, IMAGEP);
1103
1103
    
1104
1104
#if defined HAVE_IMLIB
1105
1105
    {
1106
 
        u_char *img1_rgb = image_pixels (VIMAGE (img1));
1107
 
        u_char *img2_rgb = image_pixels (VIMAGE (img2));
 
1106
        unsigned char *img1_rgb = image_pixels (VIMAGE (img1));
 
1107
        unsigned char *img2_rgb = image_pixels (VIMAGE (img2));
1108
1108
        int row, col;
1109
1109
        ImlibColor shape;
1110
1110
        Imlib_get_image_shape (imlib_id, VIMAGE (img2)->image, &shape);
1112
1112
        {
1113
1113
            for (col = 0; col < copy_w; col++)
1114
1114
            {
1115
 
                u_char *img2_pixel = img2_rgb + (row * w2 + col) * 3;
 
1115
                unsigned char *img2_pixel = img2_rgb + (row * w2 + col) * 3;
1116
1116
                if (img2_pixel[0] != shape.r
1117
1117
                    || img2_pixel[1] != shape.g
1118
1118
                    || img2_pixel[2] != shape.b)
1119
1119
                {
1120
 
                    u_char *img1_pixel;
 
1120
                    unsigned char *img1_pixel;
1121
1121
                    img1_pixel = img1_rgb + (((rep_INT (y) + row) * w1)
1122
1122
                                             + (rep_INT (x) + col)) * 3;
1123
1123
                    /* constant size, so should be inlined */
1209
1209
#endif
1210
1210
}
1211
1211
 
1212
 
u_char *
 
1212
unsigned char *
1213
1213
image_pixels (Lisp_Image *im)
1214
1214
{
1215
1215
#if defined HAVE_IMLIB
1487
1487
get_pixel (Lisp_Image *im, int x, int y)
1488
1488
{
1489
1489
    int nchannels = image_channels (im);
1490
 
    u_char *data = (image_pixels (im)
 
1490
    unsigned char *data = (image_pixels (im)
1491
1491
                    + (y * image_row_stride (im)) + (x * nchannels));
1492
1492
    repv alpha;
1493
1493
#ifdef HAVE_IMLIB
1510
1510
    {
1511
1511
        int nchannels = image_channels (im);
1512
1512
        int alpha = (length > 3) ? rep_INT (rep_CADDDR (pixel)) : 255;
1513
 
        u_char *data;
 
1513
        unsigned char *data;
1514
1514
 
1515
1515
#ifdef HAVE_GDK_PIXBUF
1516
1516
        if (alpha != 255 && nchannels < 4)