repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 56fcd326d42096f330699732668ecf24d7290ba6:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 56fcd326d42096f330699732668ecf24d7290ba6
Author: Marc Lehmann 
Date:   Sun Jun 10 10:29:26 2012 +0000

    *** empty log message ***

diff --git a/src/rxvtimg.C b/src/rxvtimg.C
index e17e0c8e22e08156fa523cb3a7bebe3717a44b05..
index ..9afd45b2ab8183b6d589dcad262a9c8d74548a7b 100644
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -65,7 +65,6 @@ rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)

   // since we require rgb24/argb32 formats from xrender we assume
   // that both 24 and 32 bpp MUST be supported by any screen that supports xrender
-  int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24;

   int byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;

@@ -79,7 +78,7 @@ rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)
   xi.bitmap_unit      = 0;         //XY only, unused
   xi.bitmap_bit_order = 0;         //XY only, unused
   xi.bitmap_pad       = BitmapPad (dpy);
-  xi.depth            = depth;
+  xi.depth            = 32;
   xi.bytes_per_line   = 0;
   xi.bits_per_pixel   = 32;         //Z only
   xi.red_mask         = 0x00000000; //Z only, unused
@@ -98,9 +97,9 @@ rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)
   xi.data = (char *)rxvt_malloc (height * xi.bytes_per_line);

   int rowstride = gdk_pixbuf_get_rowstride (pb);
-
-  assert (3 + (depth == 32) == gdk_pixbuf_get_n_channels (pb));
+  bool pb_has_alpha = gdk_pixbuf_get_has_alpha (pb);
   unsigned char *row = gdk_pixbuf_get_pixels (pb);
+
   char *line = xi.data;

   for (int y = 0; y < height; y++)
@@ -108,14 +107,14 @@ rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)
       unsigned char *src = row;
       uint32_t      *dst = (uint32_t *)line;

-      if (depth == 24)
+      if (!pb_has_alpha)
         for (int x = 0; x < width; x++)
           {
             uint8_t r = *src++;
             uint8_t g = *src++;
             uint8_t b = *src++;

-            uint32_t v = (r << 16) | (g << 8) | b;
+            uint32_t v = (255 << 24) | (r << 16) | (g << 8) | b;

             if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch)
               v = ecb_bswap32 (v);
@@ -142,7 +141,7 @@ rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)
       line += xi.bytes_per_line;
     }

-  rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height);
+  rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, PictStandardARGB32), 0, 0, width, height);
   img->alloc ();

   GC gc = XCreateGC (dpy, img->pm, 0, 0);
diff --git a/src/rxvtimg.h b/src/rxvtimg.h
index 5d149211f2138d392f7130794dcd1909b3b49f84..
index ..12de11bf9d9f39f0f90816b13a4970b7a320381a 100644
--- a/src/rxvtimg.h
+++ b/src/rxvtimg.h
@@ -13,7 +13,6 @@

 class rxvt_img
 {
-  void alloc ();
   void destroy ();
   Picture src_picture ();

@@ -39,6 +38,7 @@ public:

   rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat = RepeatNormal);
   rxvt_img (const rxvt_img &img);
+  void alloc ();

 # if HAVE_PIXBUF
   static rxvt_img *new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb); // from pixbuf
diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index 90371d78339a1d473a625208dbd68e494b096885..
index ..c39684dd74fea7af79c89afd3dae2ed748240ef8 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -66,7 +66,7 @@ typedef rxvt_img *	urxvt__img;
 static void
 parse_color (rxvt_screen *s, rxvt_color &c, SV *sv)
 {
-  //TODO: support component stuff
+  //TODO: support component stuff, 0..1
   c.set (s, SvPVbyte_nolen (sv));
 }

@@ -2046,20 +2046,17 @@ rxvt_term::background_geometry (bool border = false)

 #if HAVE_IMG

-#if 0
-
 rxvt_img *
-rxvt_term::new_img (SV *format, int width, int height)
+rxvt_term::new_img (SV *format, int width = 1, int height = 1)
 	CODE:
         XRenderPictFormat *f = SvOK (format)
                              ? XRenderFindStandardFormat (THIS->dpy, SvIV (format))
                              : XRenderFindVisualFormat   (THIS->dpy, THIS->visual);
-        RETVAL = new rxvt_img (THIS, f, width, height);
+        RETVAL = new rxvt_img (THIS, f, 0, 0, width, height);
+        RETVAL->alloc ();
 	OUTPUT:
         RETVAL

-#endif
-
 #if ENABLE_TRANSPARENCY

 rxvt_img *

-----END OF PAGE-----