diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-23 14:10:55 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-23 14:10:55 +0000 |
commit | 1c8ea1a3d80bacc938abae765c429e6af1a6eaac (patch) | |
tree | ef3dd87de027b84ec2809469e37bb4f67ae532fc /apps/graphics/tiff | |
parent | f0634683c5ac92acf1d92b80bffb17cfabc57fd4 (diff) | |
download | nuttx-1c8ea1a3d80bacc938abae765c429e6af1a6eaac.tar.gz nuttx-1c8ea1a3d80bacc938abae765c429e6af1a6eaac.tar.bz2 nuttx-1c8ea1a3d80bacc938abae765c429e6af1a6eaac.zip |
More TIFF fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3973 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/graphics/tiff')
-rw-r--r-- | apps/graphics/tiff/tiff_finalize.c | 27 | ||||
-rw-r--r-- | apps/graphics/tiff/tiff_initialize.c | 2 |
2 files changed, 24 insertions, 5 deletions
diff --git a/apps/graphics/tiff/tiff_finalize.c b/apps/graphics/tiff/tiff_finalize.c index 5c1cbefe5..0d7a222a5 100644 --- a/apps/graphics/tiff/tiff_finalize.c +++ b/apps/graphics/tiff/tiff_finalize.c @@ -215,10 +215,26 @@ int tiff_finalize(FAR struct tiff_info_s *info) int i; int j; + /* Put all of the pieces together to create the final output file. There + * are three pieces: + * + * 1) outfile: The partial output file containing the header, IFD and strip + * counts. This includes the StripOffsets and StripByteCounts that need + * to be updated. Size=outsize; + * 2) tmpfile1: This contains the offsets into tmpfile3 for each strip. The + * size of this file is tmp1size. These offsets are relative to the + * beginning of tmpfile3 and need to be offset by outsize+tmp1size. + * 3) tmpfile3: The strip data. Size is tmp2size. This is raw image data; + * no fixups are required. + */ + DEBUGASSERT(info && info->outfd >= 0 && info->tmp1fd >= 0 && info->tmp2fd >= 0); DEBUGASSERT((info->outsize & 3) == 0 && (info->tmp1size & 3) == 0); - /* Fix-up the count value in the StripByteCounts IFD entry in the outfile */ + /* Fix-up the count value in the StripByteCounts IFD entry in the outfile. + * The actual number of strips was unknown at the time that the IFD entry + * was written. + */ ret = tiff_readifdentry(info->outfd, info->filefmt->sbcifdoffset, &ifdentry); if (ret < 0) @@ -234,7 +250,10 @@ int tiff_finalize(FAR struct tiff_info_s *info) goto errout; } - /* Fix-up the count and offset values in the StripOffsets IFD entry in the outfile */ + /* Fix-up the count and offset values in the StripOffsets IFD entry in the + * outfile. The StripOffsets data will be stored immediately after the + * outfile, hence, the correct offset is outsize. + */ ret = tiff_readifdentry(info->outfd, info->filefmt->soifdoffset, &ifdentry); if (ret < 0) @@ -243,7 +262,7 @@ int tiff_finalize(FAR struct tiff_info_s *info) } tiff_put32(ifdentry.count, info->nstrips); - tiff_put32(ifdentry.offset, info->outsize + info->tmp1size); + tiff_put32(ifdentry.offset, info->outsize); ret = tiff_writeifdentry(info->outfd, info->filefmt->soifdoffset, &ifdentry); if (ret < 0) @@ -251,7 +270,7 @@ int tiff_finalize(FAR struct tiff_info_s *info) goto errout; } - /* Revind to the beginning of tmpfile1 */ + /* Rewind to the beginning of tmpfile1 */ offset = lseek(info->tmp1fd, 0, SEEK_SET); if (offset == (off_t)-1) diff --git a/apps/graphics/tiff/tiff_initialize.c b/apps/graphics/tiff/tiff_initialize.c index 67235cb31..0e5b3229c 100644 --- a/apps/graphics/tiff/tiff_initialize.c +++ b/apps/graphics/tiff/tiff_initialize.c @@ -387,7 +387,7 @@ static int tiff_putifdentry16(FAR struct tiff_info_s *info, uint16_t tag, u.w = 0; tiff_put16(u.b, value); - return tiff_putifdentry(info, tag, count, type, u.w); + return tiff_putifdentry(info, tag, type, count, u.w); } /**************************************************************************** |