#!/usr/bin/perl -w

use strict;
use GD;
use Data::Dumper;

my $range= [
    [0,350],
    [1001,1009],
    [2000,2001],
    [3000,3002],
    [3100,3108],
    [3200,3200],
    [4000,4001],
    [4100,4100],
    [4200,4200],
    [4300,4300],
    [4400,4400],
    [4500,4501],
    [4600,4600],
    [4700,4700],
    [4800,4810],
    [4900,4910],
    [5000,5000],
    [5100,5100],
    [5200,5200],
    [5300,5300],
    [5400,5400],
    [5500,5500],
    [5600,5600],
    [5700,5700],
    [5800,5800],
    [5900,5900],
    [6000,6000],
    [6100,6100],
    [6200,6200],
    [6300,6300],
    [6400,6400],
    [7000,7000],
    [8000,8000],
    [8100,8100],
    [8200,8200],
    [8300,8300],
    [8400,8400],
    [10000,10005],
    
];

#print Dumper @$range[0];

my $hoge = @$range;


for(my $i=0; $i < $hoge; $i++) {
    my @param = @$range[$i];
    for($param[0][0]..$param[0][1]){
	&makeimage($_);
    }    
}

sub makeimage {
    my $count = $_;
   
    my $image = GD::Image->new(2400,24);
    my $red = $image->colorAllocate(255,1,255);
    $image->fill(0,0,$red);
    my @rgb = $image->rgb($red);
    my $filename2 = "css/css-" .  $count * 100 . ".png";
    for(0..99){
	my $count2 = $_;
	my $filename = "../roicons/" . ($count * 100 + $count2) . ".png";

	
	my $input;
	if(-f $filename){
	    open (PNG , $filename) || die $!;
	    $input = GD::Image->new(\*PNG);
	    $image->copy($input, 24 * $count2 ,0, 0 ,0 , 24 ,24);
	    close PNG;
	}
	
    }
    my $trans =  $image->colorClosest(@rgb);
    $image->transparent($trans);
    open (PNGOUT , ">$filename2") || die $!;
    binmode STDOUT;
    print PNGOUT $image->png;
    close PNGOUT;
}
