for images missing the rowsperstrip tag.
- Fixed default parameters for crop()
- Added Preliminary specialized scaling code.
+ - Added image type detection.
=================================================================
For latest versions check the Imager-devel pages:
# Setup data source
if ( $input{'type'} eq 'jpeg' ) {
- ($self->{IMG},$self->{IPTCRAW})=i_readjpeg_wiol( $IO );
+ ($self->{IMG},$self->{IPTCRAW}) = i_readjpeg_wiol( $IO );
if ( !defined($self->{IMG}) ) {
$self->{ERRSTR}='unable to read jpeg image'; return undef;
}
}
}
- if (match && !strcmp(match, "jpeg")) {
- unsigned int x0, x1;
- rc = data->readcb(data, head, 18);
- if (rc == -1) return NULL;
- x0 = (unsigned char)head[0];
- x1 = (unsigned char)head[1];
- data->seekcb(data, -rc, SEEK_CUR);
- printf("Jpeg reread: %x %x\n", x0, x1);
- }
+ /*
+ if (match && !strcmp(match, "jpeg")) {
+ unsigned int x0, x1;
+ rc = data->readcb(data, head, 18);
+ if (rc == -1) return NULL;
+ x0 = (unsigned char)head[0];
+ x1 = (unsigned char)head[1];
+ data->seekcb(data, -rc, SEEK_CUR);
+ printf("Jpeg reread: %x %x\n", x0, x1);
+ }
+ */
if (!match &&
(rc == 18) &&
void
io_glue_commit_types(io_glue *ig) {
io_type inn = ig->source.type;
-
+
mm_log((1, "io_glue_commit_types(ig %p)\n", ig));
mm_log((1, "io_glue_commit_types: source type %d (%s)\n", inn, io_type_names[inn]));
-
+
+ if (ig->flags & 0x01) {
+ mm_log((1, "io_glue_commit_types: type already set up\n"));
+ return;
+ }
+
switch (inn) {
case BUFCHAIN:
{
break;
}
}
+ ig->flags |= 0x01; /* indicate source has been setup already */
}
/*
io_glue *ig;
mm_log((1, "io_new_bufchain()\n"));
ig = mymalloc(sizeof(io_glue));
+ memset(ig, 0, sizeof(*ig));
io_obj_setp_bufchain(&ig->source);
return ig;
}
ig = mymalloc(sizeof(io_glue));
memset(ig, 0, sizeof(*ig));
io_obj_setp_buffer(&ig->source, data, len, closecb, closedata);
+ ig->flags = 0;
return ig;
}
memset(ig, 0, sizeof(*ig));
ig->source.type = FDSEEK;
ig->source.fdseek.fd = fd;
+ ig->flags = 0;
#if 0
#ifdef _MSC_VER
io_obj_setp_cb(&ig->source, (void*)fd, _read, _write, _lseek);
mm_log((1, "io_new_cb(p %p, readcb %p, writecb %p, seekcb %p, closecb %p, "
"destroycb %p)\n", p, readcb, writecb, seekcb, closecb, destroycb));
ig = mymalloc(sizeof(io_glue));
- memset(ig, 0, sizeof(ig));
+ memset(ig, 0, sizeof(*ig));
io_obj_setp_cb2(&ig->source, p, readcb, writecb, seekcb, closecb, destroycb);
mm_log((1, "(%p) <- io_new_cb\n", ig));
typedef int ssize_t;
#endif
-struct _io_glue;
+struct io_glue;
/* Callbacks we give out */
-typedef ssize_t(*readp) (struct _io_glue *ig, void *buf, size_t count);
-typedef ssize_t(*writep)(struct _io_glue *ig, const void *buf, size_t count);
-typedef off_t (*seekp) (struct _io_glue *ig, off_t offset, int whence);
-typedef void (*closep)(struct _io_glue *ig);
-typedef ssize_t(*sizep) (struct _io_glue *ig);
+typedef ssize_t(*readp) (struct io_glue *ig, void *buf, size_t count);
+typedef ssize_t(*writep)(struct io_glue *ig, const void *buf, size_t count);
+typedef off_t (*seekp) (struct io_glue *ig, off_t offset, int whence);
+typedef void (*closep)(struct io_glue *ig);
+typedef ssize_t(*sizep) (struct io_glue *ig);
typedef void (*closebufp)(void *p);
extern char *io_type_names[];
-typedef struct _io_blink {
+typedef struct io_blink {
char buf[BBSIZ];
/* size_t cnt; */
size_t len; /* How large is this buffer = BBZIS for now */
- struct _io_blink *next;
- struct _io_blink *prev;
+ struct io_blink *next;
+ struct io_blink *prev;
} io_blink;
io_cb cb;
} io_obj;
-typedef struct _io_glue {
+typedef struct io_glue {
io_obj source;
int flags; /* Flags */
void *exdata; /* Pair specific data */
io_glue *io_new_buffer(char *data, size_t len, closebufp closecb, void *closedata);
io_glue *io_new_cb(void *p, readl readcb, writel writecb, seekl seekcb, closel closecb, destroyl destroycb);
size_t io_slurp(io_glue *ig, unsigned char **c);
-void io_glue_DESTROY(io_glue *ig);
+void io_glue_DESTROY(io_glue *ig);
#endif /* _IOLAYER_H_ */
my %files;
@files{@types} = ({ file => "testout/t101.jpg" },
{ file => "testout/t102.png" },
- { file => "testout/t103.raw", xsize=>150, ysize=>150
- #, type=>"raw" # TODO: was this there for a reason?
- },
+ { file => "testout/t103.raw", xsize=>150, ysize=>150, type=>'raw'},
{ file => "testout/t104.ppm" },
{ file => "testout/t105.gif" },
{ file => "testout/t106.tiff" },
my %mopts = %opts;
delete $mopts{file};
-
+
# read from a file handle
my $fh = IO::File->new($opts{file}, "r");
if (ok($fh, "opening $opts{file}")) {
binmode $fh;
my $fhimg = Imager->new;
- Imager::log_entry("Reading file: $opts{file}\n", -1);
+ Imager::log_entry("Reading file: $opts{file}\n", 0);
+
my $fhrc = $fhimg->read(fh=>$fh, %mopts);
- if (ok(!$fhrc, "check that type is required")) {
+ if (!ok($fhrc, "check that type is required")) {
ok ($fhimg->errstr =~ /type parameter missing/, "check for no type error");
}
else {
skip("previous test failed");
}
+ $fh->seek(0, SEEK_SET), "seek after read";
if (ok($fhimg->read(fh=>$fh, %mopts, type=>$type), "read from fh")) {
ok(Imager::i_img_diff($img->{IMG}, $fhimg->{IMG}) == 0,
"image comparison after fh read");
skip("no image to compare");
}
ok($fh->seek(0, SEEK_SET), "seek after read");
-
+
# read from a fd
my $fdimg = Imager->new;
- if (ok($fdimg->read(fd=>fileno($fh), %mopts, type=>$type),
+ if (ok($fdimg->read(fd=>fileno($fh), %mopts, type=>$type),
"read from fd")) {
ok(Imager::i_img_diff($img->{IMG}, $fdimg->{IMG}) == 0,
"image comparistion after fd read");
++$test_num;
if ($ok) {
print "ok $test_num # $msg\n";
+ Imager::log_entry("ok $test_num # $msg\n", 0);
}
else {
my $err;
my $line = "not ok $test_num # line ".(caller)[2].": $msg";
$line .= ": $err" if $err;
print $line, "\n";
+ Imager::log_entry($line."\n", 0);
}
$ok;