#!/usr/bin/perl -w # # gif-gct - find Global Color Table in a GIF # # gif-gct # # # Copyright(C) 1999 Yoshimasa Watanabe # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # The Graphics Interchange Format(c) is the Copyright property of CompuServe # Incorporated. GIF(sm) is a Service Mark property of CompuServe # Incorporated. # # # $Id: gif-gct,v 1.1 1999/01/02 12:50:20 naney Exp $ # # use strict; my $buff; #----- [read Header] ----- die if read(STDIN, $buff, 3) != 3; die if unpack('a3', $buff) ne 'GIF'; die if read(STDIN, $buff, 3) != 3; die if read(STDIN, $buff, 4) != 4; die if read(STDIN, $buff, 1) != 1; my $bits = unpack('C', $buff); my $globalColorTableFlag = ($bits & 0x80) >> 7; my $globalColorTableSize = 2 ** (($bits & 0x07) + 1); die if read(STDIN, $buff, 2) != 2; #----- [read Global Color Table] ----- if ($globalColorTableFlag) { my $i; my ($r, $g, $b); for ($i = 0; $i < $globalColorTableSize; $i++) { die if read(STDIN, $buff, 3) != 3; ($r, $g, $b) = unpack('CCC', $buff); print "$r $g $b\n"; } } exit 0; __END__ =head1 NAME gif-gct - find Global Color Table in a GIF =head1 SYNOPSIS gif-gct =head1 DESCRIPTION C displays the Global Color Table in the GIF in the standard input. =head1 AUTHOR Yoshimasa Watanabe =cut