Skip Menu |

This queue is for tickets about the Image-Imlib2 CPAN distribution.

Report information
The Basics
Id: 11181
Status: resolved
Priority: 0/
Queue: Image-Imlib2

People
Owner: leon [...] astray.com
Requestors: DON [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.03
Fixed in: (no value)



Subject: make test fails with libimlib2 >= 1.1.2 (no alpha channel unless imlib_image_set_has_alpha)
Just in case you didn't already know, I'm currently the Debian developer responsible for packaging Image::Imlib2 in Debian. Recent versions of imlib2 apparently have decided that images don't have an alpha channel unless you call imlib_image_set_has_alpha().[1] This leads to the test scripts breaking, as the alpha values are ignored.[2] I'm personally of the opinion that the alpha channel should be enabled by default in imlib2 since the memory is already spent. However, upstream seems to disagree (and I really don't know enough about the library to argue with them.) I wanted to know what your opinion is on a fix for this, before I wrote bindings for imlib_image_set_has_alpha, or called imlib_image_set_has_alpha at new time. [I kind of need to fix this soon, but I really don't want Debian's packages to differ from the ones that you're providing, as much as that is possible.] Anyway, let me know what you think I should do to resolve this. [And as always, feel free to contact me directly if you have questions or issues with the Debian package or users of the Debian package.] Don Armstrong 1: http://sourceforge.net/mailarchive/message.php?msg_id=10517308 2: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=290122
From: DON [...] cpan.org
I've attached the patch that I used to fix this bug in Debian. Feel free to use it, or suggest something different.
--- ../Image-Imlib2-1.03.orig/t/simple.t 2004-07-13 03:32:25.000000000 -0700 +++ t/simple.t 2005-01-23 01:20:34.206114956 -0800 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 7; +use Test::More tests => 9; use_ok('Image::Imlib2'); @@ -15,6 +15,12 @@ # Is it the right height? is($image->get_height, 200); +# Does has_alpha work? +is($image->has_alpha(0),0); + +# Does has_alpha work? +is($image->has_alpha(1),1); + # Does set_colour work? $image->set_colour(255, 0, 0, 255); --- ../Image-Imlib2-1.03.orig/lib/Image/Imlib2.pm 2004-07-13 03:32:25.000000000 -0700 +++ lib/Image/Imlib2.pm 2005-01-23 00:49:23.579058697 -0800 @@ -62,6 +62,9 @@ # create a new image my $image = Image::Imlib2->new(200, 200); + # Enable the alpha channel support (Debian package specific) + $image->has_alpha(1); + # set a colour (rgba, so this is transparent orange) $image->set_color(255, 127, 0, 127); @@ -350,6 +353,24 @@ $image->flip_diagonal(); +=head1 METHODS -- DEBIAN PACKAGE SPECIFIC METHODS + +The following methods may or may not be present in the upstream +version of the package (or even in future versions of the Debian +package.) They are provided to fix Debian bug #290122, and to allow +you to revert to no alpha support if you wish. + +=head2 has_alpha (BOOLEAN) + +Queries and/or sets the alpha support flag for the image. + + if($image->has_alpha){ + #do something requiring alpha support + } + # Enable the alpha channel + $image->has_alpha(1); + + =head1 METHODS (Image::Imlib2::Polygon) =head2 new --- ../Image-Imlib2-1.03.orig/lib/Image/Imlib2.xs 2004-07-13 03:32:25.000000000 -0700 +++ lib/Image/Imlib2.xs 2005-01-23 02:08:05.365324269 -0800 @@ -54,6 +54,10 @@ Imlib_Image image; image = imlib_create_image(x, y); + + imlib_context_set_image(image); + imlib_image_set_has_alpha(1); + RETVAL = image; } OUTPUT: @@ -594,6 +598,34 @@ imlib_image_flip_diagonal(); } + +int +Imlib2_has_alpha(image, ...) + Image::Imlib2 image + + PREINIT: + char value; + + PROTOTYPE: $;$ + + CODE: + { + imlib_context_set_image(image); + + if (items > 1) { + value = SvTRUE(ST(1))?1:0; + imlib_image_set_has_alpha(value); + } + + RETVAL = imlib_image_has_alpha(); + } + + OUTPUT: + RETVAL + + + + MODULE = Image::Imlib2 PACKAGE = Image::Imlib2::Polygon PREFIX= Imlib2_Polygon_ Image::Imlib2::Polygon
Thanks for the patch. I've made a Image-Imlib2-1.04 release, which will be on CPAN mirrors soon. Please tell me if this fixes your issues. CHANGES: 1.04 Thu Feb 3 15:27:41 GMT 2005 - Imlib2 1.1.2 broke our tests as it doesn't enable alpha by default (for optimisation purposes). The module now enables alpha by default when you create an image, but you can turn it off with has_alpha (thanks to Don Armstrong) - tested with Imlib2 1.2.0