| 1 | package Image::Info::XBM; | ||
| 2 | $VERSION = '1.08'; | ||
| 3 | use strict; | ||
| 4 | use Image::Xbm 1.07; | ||
| 5 | |||
| 6 | sub process_file { | ||
| 7 | my($info, $source, $opts) = @_; | ||
| 8 | |||
| 9 | local $SIG{__WARN__} = sub { | ||
| 10 | $info->push_info(0, "Warn", shift); | ||
| 11 | }; | ||
| 12 | |||
| 13 | my $i = Image::Xbm->new(-width => 0, -height => 0); | ||
| 14 | # loading the file as a separate step avoids a "-r" test, this would | ||
| 15 | # file with in-memory strings (aka fake files) | ||
| 16 | $i->load($source); | ||
| 17 | |||
| 18 | $info->push_info(0, "color_type" => "Grey"); | ||
| 19 | $info->push_info(0, "file_ext" => "xbm"); | ||
| 20 | $info->push_info(0, "file_media_type" => "image/x-xbitmap"); | ||
| 21 | $info->push_info(0, "height", $i->get(-height)); | ||
| 22 | $info->push_info(0, "resolution", "1/1"); | ||
| 23 | $info->push_info(0, "width", $i->get(-width)); | ||
| 24 | $info->push_info(0, "BitsPerSample" => 1); | ||
| 25 | $info->push_info(0, "SamplesPerPixel", 1); | ||
| 26 | |||
| 27 | $info->push_info(0, "ColorTableSize" => 2 ); | ||
| 28 | if( $opts->{L1D_Histogram} ){ | ||
| 29 | #Do Histogram | ||
| 30 | my $imgdata = $i->as_binstring(); | ||
| 31 | $info->push_info(0, "L1D_Histogram", [$imgdata =~ tr/0//d, | ||
| 32 | $imgdata =~ tr/1//d ]); | ||
| 33 | } | ||
| 34 | $info->push_info(0, "HotSpotX" => $i->get(-hotx) ); | ||
| 35 | $info->push_info(0, "HotSpotY" => $i->get(-hoty) ); | ||
| 36 | } | ||
| 37 | 1; | ||
| 38 | __END__ |