Skip to content

Commit

Permalink
Added read support for sgi .rgb files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnar Mar Hrafnkelsson committed Dec 28, 2001
1 parent 8047cbb commit 737a830
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changes
Expand Up @@ -566,7 +566,8 @@ Revision history for Perl extension Imager.
- applied T1 afm patch from Claes Jacobsson
- split IM_INCPATH and IM_LIBPATH with $Config{path_sep}, so they
work on Windows

- Added memory pools for easy cleanup of temp buffers
- Added read support for sgi .rgb files.
=================================================================

For latest versions check the Imager-devel pages:
Expand Down
14 changes: 12 additions & 2 deletions Imager.pm
Expand Up @@ -895,7 +895,7 @@ sub read {
$self->{ERRSTR}='format not supported'; return undef;
}

my %iolready=(jpeg=>1, png=>1, tiff=>1, pnm=>1, raw=>1, bmp=>1, tga=>1);
my %iolready=(jpeg=>1, png=>1, tiff=>1, pnm=>1, raw=>1, bmp=>1, tga=>1, rgb=>1);

if ($iolready{$input{'type'}}) {
# Setup data source
Expand Down Expand Up @@ -950,12 +950,21 @@ sub read {
$self->{IMG}=i_readtga_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}=$self->_error_as_msg();
# $self->{ERRSTR}='unable to read tga image';
return undef;
}
$self->{DEBUG} && print "loading a tga file\n";
}

if ( $input{'type'} eq 'rgb' ) {
$self->{IMG}=i_readrgb_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}=$self->_error_as_msg();
return undef;
}
$self->{DEBUG} && print "loading a tga file\n";
}


if ( $input{'type'} eq 'raw' ) {
my %params=(datachannels=>3,storechannels=>3,interleave=>1,%input);

Expand Down Expand Up @@ -2233,6 +2242,7 @@ sub def_guess_type {
return 'png' if ($ext eq "png");
return 'bmp' if ($ext eq "bmp" || $ext eq "dib");
return 'tga' if ($ext eq "tga");
return 'rgb' if ($ext eq "rgb");
return 'gif' if ($ext eq "gif");
return ();
}
Expand Down
25 changes: 25 additions & 0 deletions Imager.xs
Expand Up @@ -1902,6 +1902,31 @@ i_readtga_wiol(ig, length)
int length


undef_int
i_writergb_wiol(im,ig, wierdpack, compress, idstring)
Imager::ImgRaw im
Imager::IO ig
int wierdpack
int compress
char* idstring
PREINIT:
SV* sv1;
int rc;
int idlen;
CODE:
idlen = SvCUR(ST(4));
RETVAL = i_writergb_wiol(im, ig, wierdpack, compress, idstring, idlen);
OUTPUT:
RETVAL


Imager::ImgRaw
i_readrgb_wiol(ig, length)
Imager::IO ig
int length



Imager::ImgRaw
i_scaleaxis(im,Value,Axis)
Imager::ImgRaw im
Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Expand Up @@ -64,7 +64,7 @@ if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
filters.o dynaload.o stackmach.o datatypes.o
regmach.o trans2.o quant.o error.o convert.o
map.o tags.o palimg.o maskimg.o img16.o rotate.o
bmp.o tga.o color.o fills.o imgdouble.o);
bmp.o tga.o rgb.o color.o fills.o imgdouble.o);

%opts=(
'NAME' => 'Imager',
Expand Down
1 change: 1 addition & 0 deletions feat.h
Expand Up @@ -29,5 +29,6 @@ static char *i_format_list[]={
"pnm",
"bmp",
"tga",
"rgb",
NULL};

3 changes: 3 additions & 0 deletions image.h
Expand Up @@ -564,6 +564,9 @@ extern i_img *i_readbmp_wiol(io_glue *ig);
i_img * i_readtga_wiol(io_glue *ig, int length);
undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);

i_img * i_readrgb_wiol(io_glue *ig, int length);
undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);

i_img * i_scaleaxis(i_img *im, float Value, int Axis);
i_img * i_scale_nn(i_img *im, float scx, float scy);
i_img * i_haar(i_img *im);
Expand Down

0 comments on commit 737a830

Please sign in to comment.