[gimp-perl] Handle alpha channel right.



commit e13656d6fed0c7569dccf876b80decf35087124c
Author: Ed J <edj src gnome org>
Date:   Sun May 25 16:10:09 2014 +0100

    Handle alpha channel right.

 examples/colorhtml |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/examples/colorhtml b/examples/colorhtml
index 3a4d5d3..7ab8e7a 100755
--- a/examples/colorhtml
+++ b/examples/colorhtml
@@ -60,7 +60,7 @@ podregister {
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-<title>css color html by The GIMP</title>
+<title>css color html by GIMP</title>
 <link rel="stylesheet" type="text/css" href="$file">
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 </head>
@@ -81,11 +81,14 @@ HEADER
     $io->print("<html><body bgcolor=black>\n<font size=\"$font_size\"><pre>\n");
   }
   my %colors;
+  my $bpp = $region->bpp;
+  die "Expected bpp to be either 3 or 4" unless $bpp == 3 or $bpp == 4;
+  my $pixel_re = '(.{3})' . ($bpp == 3 ? '' : '.');
   for (my $y = 0; $y < $h; $y++) {
     my $pel = $region->get_row2 (0, $y, $w);
     push @chars,@data while @chars < $w;
     if ($use_css) {
-       $pel =~ s{(...)}{
+       $pel =~ s{$pixel_re}{
          "<span class=\"N".unpack("H*",$1)."\">".shift(@chars)."</span>"
        }ges;
        while ($pel =~ /"N([0-9a-fA-F]{6})"/g) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]