all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Julien Danjou <julien@danjou.info>
To: 7316@debbugs.gnu.org
Cc: rfrancoise@debian.org
Subject: bug#7316: 24.0.50; [PATCH] Add support for GIF transparency
Date: Tue, 02 Nov 2010 10:39:59 +0100	[thread overview]
Message-ID: <sa3d3qogj2o.fsf@cigue.easter-eggs.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]


Attached are 2 patches adding correct transparency support for GIF
images inside Emacs.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gif-1.diff --]
[-- Type: text/x-diff, Size: 6103 bytes --]

From nobody Tue Nov  2 10:39:02 2010
Return-Path: <emacs-devel-bounces+julien=danjou.info@gnu.org>
Delivered-To: jd@danjou.info
Received: by mx1.naquadah.org (Postfix, from userid 8)
	id 759E15C156; Wed, 27 Oct 2010 18:21:47 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	prometheus.naquadah.org
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=4.5 tests=BAYES_00,RCVD_IN_DNSWL_MED
	autolearn=ham version=3.3.1
Received: from lists.gnu.org (lists.gnu.org [199.232.76.165])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.naquadah.org (Postfix) with ESMTPS id CFC485C0FB
	for <julien@danjou.info>; Wed, 27 Oct 2010 18:21:37 +0200 (CEST)
Received: from localhost ([127.0.0.1]:41338 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1PB8jo-0007sh-T3
	for julien@danjou.info; Wed, 27 Oct 2010 12:20:32 -0400
Received: from [140.186.70.92] (port=36740 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PB8DC-0002Ay-0N
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:47:02 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdanjou@easter-eggs.fr>) id 1PB7Uj-0008Td-Q7
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:01:05 -0400
Received: from coquelicot-s.easter-eggs.com ([213.215.37.94]:57239)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdanjou@easter-eggs.fr>) id 1PB7Uj-0008TR-Kj
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:00:53 -0400
Received: from cigue.easter-eggs.fr (cigue.easter-eggs.fr [10.0.0.33])
	by rose.easter-eggs.fr (Postfix) with ESMTPS id 307B71409D;
	Wed, 27 Oct 2010 17:00:49 +0200 (CEST)
Received: from jdanjou by cigue.easter-eggs.fr with local (Exim 4.72)
	(envelope-from <jdanjou@cigue.easter-eggs.fr>)
	id 1PB7Ui-00012M-Lo; Wed, 27 Oct 2010 17:00:52 +0200
From: Julien Danjou <julien@danjou.info>
To: emacs-devel@gnu.org
Date: Wed, 27 Oct 2010 17:00:50 +0200
Message-Id: <1288191651-3958-1-git-send-email-julien@danjou.info>
X-Mailer: git-send-email 1.7.2.3
In-Reply-To: <sa3r5fbisy7.fsf@cigue.easter-eggs.fr>
References: <sa3r5fbisy7.fsf@cigue.easter-eggs.fr>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH 1/2] image: add support for GIF transparency
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
X-Mailman-Copy: yes
Sender: emacs-devel-bounces+julien=danjou.info@gnu.org
Errors-To: emacs-devel-bounces+julien=danjou.info@gnu.org

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |    4 ++++
 src/image.c   |   27 +++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 51645ac..3d9b6bf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-27  Julien Danjou  <julien@danjou.info>
+
+	* image.c (gif_load): Add support for transparency.
+
 2010-10-26  Juanma Barranquero  <lekktu@gmail.com>
 
 	* eval.c (init_eval_once): Set max_lisp_eval_depth to 600;
diff --git a/src/image.c b/src/image.c
index b7edf05..e9b85fa 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7096,12 +7096,15 @@ gif_read_from_memory (GifFileType *file, GifByteType *buf, int len)
 static const int interlace_start[] = {0, 4, 2, 1};
 static const int interlace_increment[] = {8, 8, 4, 2};
 
+#define GIF_LOCAL_DESCRIPTOR_EXTENSION 249
+
 static int
 gif_load (struct frame *f, struct image *img)
 {
   Lisp_Object file, specified_file;
   Lisp_Object specified_data;
   int rc, width, height, x, y, i;
+  boolean transparent_p;
   XImagePtr ximg;
   ColorMapObject *gif_color_map;
   unsigned long pixel_colors[256];
@@ -7110,6 +7113,7 @@ gif_load (struct frame *f, struct image *img)
   int ino, image_height, image_width;
   gif_memory_source memsrc;
   unsigned char *raster;
+  unsigned int transparency_color_index;
 
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -7182,6 +7186,16 @@ gif_load (struct frame *f, struct image *img)
       return 0;
     }
 
+  for(i = 0; i < gif->SavedImages[ino].ExtensionBlockCount; i++)
+    if (gif->SavedImages[ino].ExtensionBlocks[i].Function == GIF_LOCAL_DESCRIPTOR_EXTENSION
+        && gif->SavedImages[ino].ExtensionBlocks[i].ByteCount == 4
+        /* Transparency enabled? */
+        && gif->SavedImages[ino].ExtensionBlocks[i].Bytes[0] & 1)
+    {
+        transparent_p = 1;
+        transparency_color_index = (unsigned char) gif->SavedImages[ino].ExtensionBlocks[i].Bytes[3];
+    }
+
   img->corners[TOP_CORNER] = gif->SavedImages[ino].ImageDesc.Top;
   img->corners[LEFT_CORNER] = gif->SavedImages[ino].ImageDesc.Left;
   image_height = gif->SavedImages[ino].ImageDesc.Height;
@@ -7220,10 +7234,15 @@ gif_load (struct frame *f, struct image *img)
   if (gif_color_map)
     for (i = 0; i < gif_color_map->ColorCount; ++i)
       {
-        int r = gif_color_map->Colors[i].Red << 8;
-        int g = gif_color_map->Colors[i].Green << 8;
-        int b = gif_color_map->Colors[i].Blue << 8;
-        pixel_colors[i] = lookup_rgb_color (f, r, g, b);
+        if (transparent_p && transparency_color_index == i)
+            pixel_colors[i] = FRAME_BACKGROUND_PIXEL (f);
+        else
+          {
+            int r = gif_color_map->Colors[i].Red << 8;
+            int g = gif_color_map->Colors[i].Green << 8;
+            int b = gif_color_map->Colors[i].Blue << 8;
+            pixel_colors[i] = lookup_rgb_color (f, r, g, b);
+          }
       }
 
 #ifdef COLOR_TABLE_SUPPORT
-- 
1.7.2.3



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: gif-2.diff --]
[-- Type: text/x-diff, Size: 4343 bytes --]

From nobody Tue Nov  2 10:39:05 2010
Return-Path: <emacs-devel-bounces+julien=danjou.info@gnu.org>
Delivered-To: jd@danjou.info
Received: by mx1.naquadah.org (Postfix, from userid 8)
	id 5BFBD5C17C; Wed, 27 Oct 2010 18:09:48 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	prometheus.naquadah.org
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=4.5 tests=BAYES_00,RCVD_IN_DNSWL_MED
	autolearn=ham version=3.3.1
Received: from lists.gnu.org (lists.gnu.org [199.232.76.165])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.naquadah.org (Postfix) with ESMTPS id EB16A5C159
	for <julien@danjou.info>; Wed, 27 Oct 2010 18:09:45 +0200 (CEST)
Received: from localhost ([127.0.0.1]:41062 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1PB8ZL-0008PA-M2
	for julien@danjou.info; Wed, 27 Oct 2010 12:09:43 -0400
Received: from [140.186.70.92] (port=42377 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PB8DB-0002x0-LR
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:46:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdanjou@easter-eggs.fr>) id 1PB7Uk-0008Tu-9U
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:01:08 -0400
Received: from coquelicot-s.easter-eggs.com ([213.215.37.94]:57242)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdanjou@easter-eggs.fr>) id 1PB7Uk-0008Ta-1x
	for emacs-devel@gnu.org; Wed, 27 Oct 2010 11:00:54 -0400
Received: from cigue.easter-eggs.fr (cigue.easter-eggs.fr [10.0.0.33])
	by rose.easter-eggs.fr (Postfix) with ESMTPS id E88E01425C;
	Wed, 27 Oct 2010 17:00:49 +0200 (CEST)
Received: from jdanjou by cigue.easter-eggs.fr with local (Exim 4.72)
	(envelope-from <jdanjou@cigue.easter-eggs.fr>)
	id 1PB7Uj-00012P-EL; Wed, 27 Oct 2010 17:00:53 +0200
From: Julien Danjou <julien@danjou.info>
To: emacs-devel@gnu.org
Date: Wed, 27 Oct 2010 17:00:51 +0200
Message-Id: <1288191651-3958-2-git-send-email-julien@danjou.info>
X-Mailer: git-send-email 1.7.2.3
In-Reply-To: <sa3r5fbisy7.fsf@cigue.easter-eggs.fr>
References: <sa3r5fbisy7.fsf@cigue.easter-eggs.fr>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH 2/2] image: add support for specified :background on GIF
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
X-Mailman-Copy: yes
Sender: emacs-devel-bounces+julien=danjou.info@gnu.org
Errors-To: emacs-devel-bounces+julien=danjou.info@gnu.org

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |    1 +
 src/image.c   |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3d9b6bf..65d2730 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,6 +1,7 @@
 2010-10-27  Julien Danjou  <julien@danjou.info>
 
 	* image.c (gif_load): Add support for transparency.
+	(gif_load): Add support for specified :background.
 
 2010-10-26  Juanma Barranquero  <lekktu@gmail.com>
 
diff --git a/src/image.c b/src/image.c
index e9b85fa..ef6a6d0 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7235,7 +7235,14 @@ gif_load (struct frame *f, struct image *img)
     for (i = 0; i < gif_color_map->ColorCount; ++i)
       {
         if (transparent_p && transparency_color_index == i)
-            pixel_colors[i] = FRAME_BACKGROUND_PIXEL (f);
+          {
+            Lisp_Object specified_bg
+              = image_spec_value (img->spec, QCbackground, NULL);
+            if (STRINGP (specified_bg))
+              pixel_colors[i] = x_alloc_image_color (f, img, specified_bg, FRAME_BACKGROUND_PIXEL (f));
+            else
+              pixel_colors[i] = FRAME_BACKGROUND_PIXEL (f);
+          }
         else
           {
             int r = gif_color_map->Colors[i].Red << 8;
-- 
1.7.2.3



[-- Attachment #4: Type: text/plain, Size: 88 bytes --]


Cheers,
-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

             reply	other threads:[~2010-11-02  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-02  9:39 Julien Danjou [this message]
     [not found] ` <handler.7316.B.128870495229908.ack@debbugs.gnu.org>
2010-11-05 13:24   ` bug#7316: Acknowledgement (24.0.50; [PATCH] Add support for GIF transparency) Julien Danjou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sa3d3qogj2o.fsf@cigue.easter-eggs.fr \
    --to=julien@danjou.info \
    --cc=7316@debbugs.gnu.org \
    --cc=rfrancoise@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.