Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas014.isp.belgacom.be (localhost [127.0.0.1])
        by inav007.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k3M4oxdv005831
        for <joris.at.lebbeke@skynet.be>; Sat, 22 Apr 2006 06:50:59 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx017.isp.belgacom.be (inmx017.isp.belgacom.be [195.238.4.129])
        by inas014.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k3M4opWH028478
        for <joris.at.lebbeke@skynet.be>; Sat, 22 Apr 2006 06:50:53 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx017.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k3M4of9M029300
        for <joris.at.lebbeke@skynet.be>; Sat, 22 Apr 2006 06:50:46 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k3M4faYO019459;
	Sat, 22 Apr 2006 00:42:38 -0400
Received: from omta05sl.mx.bigpond.com (omta05sl.mx.bigpond.com
	[144.140.93.195])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k3M4fPq9019456
	for <tiff@lists.maptools.org>; Sat, 22 Apr 2006 00:41:27 -0400
Received: from prionotes.cuneata.net ([61.9.204.42])
	by omta05sl.mx.bigpond.com with ESMTP id
	<20060422044106.EKTL25409.omta05sl.mx.bigpond.com@prionotes.cuneata.net>;
	Sat, 22 Apr 2006 04:41:06 +0000
From: Brad Hards <bradh@frogmouth.net>
To: tiff@lists.maptools.org, glennw@swiftview.com
Date: Sat, 22 Apr 2006 13:37:48 +1000
User-Agent: KMail/1.9.1
MIME-Version: 1.0
Message-Id: <200604221337.54640.bradh@frogmouth.net>
Cc: 
Subject: [Tiff] Microsoft Document Imaging status / snapshot
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1539176979=="
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.000015ff
X-MSP-STORE: Sat, 22 Apr 2006 06:51:07 +0200
Status:   

--===============1539176979==
Content-Type: multipart/signed; boundary="nextPart6105240.OAhjMMNYYz";
	protocol="application/pgp-signature"; micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart6105240.OAhjMMNYYz
Content-Type: multipart/mixed;
  boundary="Boundary-01=_OUaSEnKK6JHfLjf"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_OUaSEnKK6JHfLjf
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

After a very long hiatus (I've been working on some Qt-based crypto), I=20
recently spent a little bit of time working on the .mdi file format=20
extensions to tiff.

I've almost got the "OCR'd text" tag sorted out:
37679 - looks like the text version of the document contents. The
content are 0x01 0x00, followed by a length (4 byte aka long) which
has a value that is 6 bytes less than the actual length of this field,
followed by the ascii text version. Each phrase is delimited by a
space followed by a newline  (0x20 0x0a aka ' \n'). The end is 0x0d
0x00. There are sometimes additional bytes (e.g. 0xe2  0x80  0x9c)
which appear to be some kind of character / symbol encoding.
Combinations include:
0xef  0x82  0xa7  =3D some kind of bullet point symbol
0xef  0x82  0xb7  =3D some kind of bullet point symbol (different to a7)
0xe2  0x80  0x93  =3D em-dash
0xe2  0x80  0x9c  =3D `` (smart doublequotes, left side of quoted material)
0xe2  0x80  0x9d  =3D '' (smart doublequotes, right side of quoted material)
0xe2  0x80  0x99  =3D ' (apostrophe of some kind)
0xe2  0x80  0xa6
0xe2  0x80  0x94 =3D short dash?
0xc3  0xa9 =3D e with grave. (00a9 is the unicode equivalent, perhaps
this will form some pattern)

My current set of notes is attached.

I've been hacking libtiff to try to figure out what is going on. A cvs diff=
 is=20
also attached - you'll need the tif_mdi.c file as well, if you want it to=20
compile (it goes into libtiff/libtiff/).

Work on the actual image content (compression type) has only just started.=
=20
Right now I have absolutely no idea what the format could be, although it=20
certainly does appear to use some kind of compression format. I generated a=
=20
few trivial files (a large filled blue rectangle, same rectangle without=20
fill, same rectangle in a slightly different shade of blue, same rectangle =
in=20
green) Here is what the content looks like:
/home/bradh/mdi/greenrect.MDI:
char count: 336
02 00 00 00 7b 00 00 00 ac 02 00 00 03 00 00 00 00 00 00 00 ff ff ff ff 00 =
00=20
00 00 78 01 5d 91 bd 4a c4 50 10 85 cf cd 46 37 82 8a 18 11 41 8b b5 f0 0f =
1b
 c1 b5 b7 d1 46 5c c4 42 7b d1 42 10 0b 5d b0 dd c2 c2 97 c8 1b 58 28 68 ef=
 33=20
f8 04 3e 85 ed fa 9d 35 37 9b cd c0 c9 3d 33 77 66 ce 64 6e 90 f4 0c 8a 20 e
5 89 d4 cb e0 6d 02 a5 65 e7 52 da 97 3a 47 a7 c7 52 d0 2b 39 eb dc b5 c0 2=
c=20
b8 2b f3 de 66 a4 8f 39 e9 1b 7f 87 5e 75 3b e8 b6 b4 ff 92 ea 4c 0f ba d5 =
bd
fa ea 80 1b 3d f2 b5 6d 00 f7 42 76 10 39 6e c5 e7 e1 ab 04 16 40 34 a4 26 =
fc=20
2b 7c f7 b0 f4 75 c9 97 a8 7b 82 73 4e 58 d4 e0 57 2b 8d 29 f8 2e 59 2b e0 =
eb
 67 38 ac 23 e6 37 e7 5b 26 d7 9a ae 59 2c b9 f5 ad e7 b8 67 ac f3 13 fc 43=
 b0=20
07 d0 63 0b ff f3 ba a6 fe 6f ef ec f2 d3 c5 a5 45 3f ce e1 b9 b7 b8 b3 ae 6
b 47 36 10 2f 33 de a5 e3 17 c0 5a cd b7 b5 76 11 f2 a4 97 19 45 bb 08 46 9=
e=20
6c 12 5f 03 a3 46 9c 95 d1 3b 6a fb ee 12 74 41 b3 ef 34 b1 df 74 dc 2f f6 =
77
2c d6 37 77 b8 4d 8d 77 e5 be 91 7b 76 de bc 7a 37 ef c6 7b fc 03 fe c8 3b =
4d

/home/bradh/mdi/bluerect.MDI:
char count: 337
02 00 00 00 7b 00 00 00 ac 02 00 00 03 00 00 00 00 00 00 00 ff ff ff ff 00 =
00=20
00 00 78 01 5d 91 bd 4a c4 50 10 85 4f b2 d1 8d a0 22 46 44 d0 62 2d fc c3 =
46
 70 ed 6d dc 66 71 11 0b ed 45 0b 41 2c 74 c1 d6 c2 c2 97 c8 1b 58 28 28 58=
 fa=20
0c 3e 81 4f 61 1b bf b3 e6 66 b3 19 38 b9 67 e6 ce cc 99 cc 8d 24 3d 81 3c 9
2 b2 58 1a a4 f0 36 81 d2 d2 53 29 19 4a 9d a3 e3 9e 14 e9 85 9c 75 ee 5a 6=
0=20
16 dc 94 79 af 33 d2 fb 9c f4 8d bf 43 af ba 1d 74 5b da 7f 4e 74 a2 3b 5d =
eb
56 43 75 c0 95 ee f9 da 36 80 7b 21 fb 18 38 6e c5 e7 e1 ab 04 16 40 30 a4 =
26=20
fc 0b 7c f7 b0 f4 65 c9 97 a8 7b 80 73 4e 58 d0 e0 57 2b 8d 29 f8 2e 59 2b =
e0
 eb a7 28 ea 08 f9 cd f9 96 c9 b5 a6 6b 16 4b 6e 7d eb 39 ee 19 eb bc 8f 7f=
 08=20
f6 00 7a 6c e1 7f 5e d7 d4 ff ed 8d 5d 7e b8 b8 b4 e0 87 39 3c f7 16 77 d6 7
5 ed c8 3e 0b 5e 66 bc 4b c7 cf 80 b5 9a 6f 6b ed 3c ca e2 41 6a e4 ed 3c 3=
2=20
b2 78 93 f8 1a 18 35 e2 ac 8c de 41 db 77 e7 a0 0b 9a 7d a7 89 fd 26 e3 7e =
a1
bf 63 a1 be b9 c3 6d 6a bc 2b f7 0d dc b3 f3 e6 d5 bb 79 37 de e3 1f b4 ae =
3d=20
bb

/home/bradh/mdi/blue8rect.MDI:
char count: 339
02 00 00 00 7b 00 00 00 ac 02 00 00 03 00 00 00 00 00 00 00 ff ff ff ff 00 =
00=20
00 00 78 01 5d 91 bf 2e 04 61 14 c5 cf cc 0e 3b 12 44 cc 46 24 14 ab f0 2f =
1a
 89 d5 6b 6c 23 36 a2 a0 17 0a 89 28 d8 44 ab 50 78 05 c5 bc 81 82 84 de 03=
 a8=20
3c 81 a7 d0 8e df 61 be d9 d9 b9 c9 99 ef dc fb dd 7b cf 9d fb 45 92 1e 40 1
e 49 59 2c 0d 52 78 9b 40 69 e9 b1 94 0c a5 ee fe 61 5f 8a f4 4c ce 0a 77 2=
d=20
30 0d ae ca bc 97 29 e9 6d 46 fa c2 df a4 57 dd 76 7b 2d ed 3c 26 3a d2 8d =
2e
75 ad a1 ba e0 42 b7 7c 6d ab c0 bd 90 bd 0f 1c b7 e2 b3 f0 25 02 73 20 18 =
52=20
63 fe 19 be 7b 58 fa bc e4 1d ea ee e0 9c 63 16 34 f8 d5 4a 63 02 be 45 d6 =
22
 f8 f8 2e 8a 3a 42 7e 73 be 05 72 ad e9 9a f9 92 5b df 7a 8e 7b c6 3a 3f c0=
 df=20
03 db 00 3d b6 f0 3f af 6b ea ff f6 ca 2e df 5d 5c 5a f0 c3 1c 9e 7b 9d 3b e
b ba d6 f6 f4 59 f0 32 a3 5d 3a 7e 02 ac d5 7c 5b 6b e7 51 16 0f 52 23 6f e=
7=20
91 91 c5 6b c4 97 c1 5f 23 ce 60 ee 1d b4 7d 77 0a 7a a0 d9 77 92 d8 4f 32 =
ea
17 fa 3b 16 ea 9b 3b dc a0 c6 bb 72 df c0 3d 3b 6f 5e bd 9b 77 e3 3d fe 02 =
aa=20
91 3f 15

/home/bradh/mdi/bluenofill.MDI:
char count: 299
02 00 00 00 7b 00 00 00 34 02 00 00 03 00 00 00 00 00 00 00 ff ff ff ff 00 =
00=20
00 00 78 01 5d 91 b1 4a c4 50 10 45 6f 62 34 11 74 11 57 44 d0 62 1b c5 65 =
1b
 c1 d8 6f a3 8d b8 88 8d bd 68 21 88 85 2e d8 5a 58 ec 4f e4 1f 14 14 2c fd=
 06=20
bf c0 af b0 8d e7 e2 7b 21 d9 81 9b 77 67 de cc bb 33 93 44 d2 0b a8 12 a9 9
f 4a 93 02 9e 13 08 56 5c 48 d9 54 1a 1c 9f 9d 48 89 4a 72 b6 b9 e3 d0 0a b=
8=20
0b 79 af cb d2 fb aa f4 8d 3f e4 ad b6 1d 95 0b 3a 9c 65 3a d7 83 6e 75 af =
a9
06 e0 46 8f 7c 6d bb c0 6f 21 fb 1c 39 6e c3 7b 70 6b ae 81 68 48 75 fc 2b =
7c=20
bf 61 e9 eb c0 37 a8 7b 82 73 76 2c 6a 30 6a a3 b1 08 1f 91 b5 05 be 7e ea =
ba
 8d 98 3f df df 26 b9 d6 74 cd 7a e0 d6 b7 9e e3 ee b1 cd 4f f1 c7 e0 00 a0=
 c7=20
16 fe fb 75 4d 7b b6 37 76 f9 e1 e2 60 d1 df c3 df 01 ce ef d8 67 9d c6 1e 7
d 77 09 4a 30 ff 4f 97 88 fd 66 55 5e 25 46 3f 9d 14 46 95 3b 16 eb 3d e3 3=
e=20
79 71 97 ec be d9 9f 7b f4 3c 7f e9 85 33 2a

There are some obvious similarities between the files, but what they mean=20
isn't clear to me. I'd appreciate any suggestions though!

I'm happy to provide the test file collection (they are each less than=20
5kbytes) to anyone with an interest - just let me know.

Brad

--Boundary-01=_OUaSEnKK6JHfLjf
Content-Type: text/plain;
  charset="us-ascii";
  name="mdi-notes.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mdi-notes.txt"

MDI contains images of the page, and the text that it contains.
Based on TIFF format.

Office Document Imaging creates MDI files in these formats:
 - Monochrome One bit per pixel, MODI BW compression
 - Grayscale 8 bits per pixel, MODI Color compression
 - Color 24 bits RGB, MODI Color compression

Office Document Imaging supports:=20
 - All compression types listed in the TIFF 6.0 specification.
 - Different compression types for each page of a multi-page document.=20
 - TIFF images with 1-bit, 4-bit, 8-bit, or 24-bit color depth (both palett=
e and non-palette).
 - MDI images with 1-bit, 8-bit, or 24-bit color depth.
 - RGB and CMYK color spaces.
 - Tiled images.=20

Office Document Imaging does not support:
 - YCbCr color space, except when the image is JPEG.
 - CIE Lab color space.
 - Images with more than five samples per pixel, or a sample size larger th=
an 32 bits.
 - Images in Planar format.

MDI support document annotations.
 - add text as a note or comment
 - apply highlighting to important text
 - draw freeform text or shapes to circle text in question
 - insert a picture in your document by using the buttons on the
Annotations toolbar.
 - Move, resize, and remove annotations.
 - Select the font and background color (if any) for text you add to your d=
ocument.
 - Choose the thickness and color of ink for the pens you use to add highli=
ghting and drawings.=20
 - Make your annotations a permanent part of your document.
 - Print your document with or without annotations.


Each MDI document consists of an ordered collection of pages (images),
plus metadata.

The metadata has a standard set of properties, plus a custom
set. Standard ("built in") properties includes "Title", "Author" and
"Creation Date". Title and Author may not be present.
"Last print date" and "Last save time" are "available but not used"

=46ile format can vary:
 - DEFAULTVALUE   -1
 - MDI   4
 - TIFF   1
 - TIFF_LOSSLESS   2

Compression level can vary
 - High (2)
 - Low (0)
 - Medium (1)

Compression type (259, 0x0103) can vary:
 - MODI_BLC  34718
 - MODI_PTC  34720
 - MODI_VECTOR   34719
 - TIFF_CCITT1D   2
 - TIFF_CCITT3   3
 - TIFF_CCITT4   4
 - TIFF_JPEG   7
 - TIFF_JPEG6   6
 - TIFF_LZW   5
 - TIFF_NONE   1
 - TIFF_PACK   32773
 - UNKNOWN   0

Variable font families:
 - Century   3
 - DEFAULT   6
 - Helvetica   1
 - HelveticaCentury   5
 - Times   2
 - TimesCentury   4

Variable face styles:
 - BOLD   3
 - BOLD_ITALIC   4
 - ITALIC   2
 - ROMAN   1

Serif styles:
 - SerifRND   4
 - SerifSANS   1
 - SerifSQ   3
 - SerifSTYLE_UNKNOWN   5
 - SerifTHIN   2

Languages:
 - CHINESE_SIMPLIFIED   2052
 - CHINESE_TRADITIONAL   1028
 - CZECH   5
 - DANISH   6
 - DUTCH   19
 - ENGLISH   9
 - FINNISH   11
 - FRENCH   12
 - GERMAN   7
 - GREEK   8
 - HUNGARIAN   14
 - ITALIAN   16
 - JAPANESE   17
 - KOREAN   18
 - NORWEGIAN   20
 - POLISH   21
 - PORTUGUESE   22
 - RUSSIAN   25
 - SPANISH   10
 - SWEDISH   29
 - SYSDEFAULT   2048
 - TURKISH   31

Thumbnail sizes:
 - LARGE   3
 - MAXIMUM   3
 -_MEDIUM   2
 - SMALL   1
 - TINY   0

Each page can have different image properties:
 - picture of page
 - thumbnail of page
 - BitsPerPixel  - The bits per pixel.
 - Compression The compression level.
 - Layout The results of OCR on the page.=20
 - PixelHeight The height in pixels.=20
 - PixelWidth The width in pixels.=20
 - The X-axis pixels per inch.=20
 - YDPI The Y-axis pixels per inch.

Layout - provides summary information (such as the number of
words) about the recognized text on the page and gives access to the
recognized text itself and to each individual word in the text.

The Word object exposes additional information about each word's font, its
location on the page, and even the OCR engine's RecognitionConfidence
factor, which estimates the likelihood of a recognition error:  =20

Layout properties
 - Language  The language setting used by the OCR process.=20
 - NumChars The number of characters in the recognized text.=20
 - NumFonts The number of fonts in the recognized text.=20
 - NumWords The number of words in the recognized text.=20
 - Text The recognized text as a single string.=20
 - Words The recognized text as a collection of words.=20
  =20
Word
 - Font -  The MiFont used by the word.=20
 - FontId The index into the implicit fonts collection.=20
 - Id The index into the page's Words collection.
 - LineId The index into the implicit lines collection.
 - RecognitionConfidence The OCR engine's recognition confidence factor.
 - Rects The bounding rectangles that include the word.
 - RegionId The index into the implicit regions collection.
 - Text The text of the word.=20

MiFont
 - FaceStyle Font face style; for example, "bold".=20
 - Family Font family; for example, "Times New Roman".
 - FontSize Font size in points.
 - SerifStyle Font serif style; for example, "thin". =20

Doing command line OCR:
If the TIFF image is monochrome, it will be compressed in TIFF CCITT G4 for=
mat.
If the TIFF image is grayscale or color, it will be compressed in TIFF 6.0 =
JPEG format.
If the MDI image is monochrome, it will be compressed in MODI BW format.
If the MDI image is grayscale or color, it will be compressed in MODI Color=
 format.
If the image is over 900 dots per inch (dpi), it will be saved at 900 dpi.


Uses different magic number to TIFF: 0x5045
Same version number: 0x002a

There are unknown properties:
37679 - appears on every page, always starts with 0x01 0x00, then varies
37680 - only appears to occur on the first page, always appears to be lengt=
h 4096, always starts with 0xd0 0xcf 0x11 0xe0 0xa1 0xb1 0x1a 0xe1, then a =
string of zeros, and then varies.
37681 - appears on every page, always stars with 0x02 0x00 (+ 0x00, 0x00?),=
 then varies

These unknown properties appear to occur in both TIFF and MDI files.

37679 - looks like the text version of the document contents. The
content are 0x01 0x00, followed by a length (4 byte aka long) which
has a value that is 6 bytes less than the actual length of this field,
followed by the ascii text version. Each phrase is delimited by a
space followed by a newline  (0x20 0x0a aka ' \n'). The end is 0x0d
0x00. There are sometimes additional bytes (e.g. 0xe2  0x80  0x9c)
which appear to be some kind of character / symbol encoding.
Combinations include:
0xef  0x82  0xa7  =3D some kind of bullet point symbol
0xef  0x82  0xb7  =3D some kind of bullet point symbol (different to a7)
0xe2  0x80  0x93  =3D em-dash
0xe2  0x80  0x9c  =3D `` (smart doublequotes, left side of quoted material)
0xe2  0x80  0x9d  =3D '' (smart doublequotes, right side of quoted material)
0xe2  0x80  0x99  =3D ' (apostrophe of some kind)
0xe2  0x80  0xa6
0xe2  0x80  0x94
0xc3  0xa9 =3D e with grave. (00a9 is the unicode equivalent, perhaps
this will form some pattern)

37680 might be some kind of metadata dictionary. It is located at the end of
the file, and there are 16-bit wide characters that look like "Root Entry",=
=20
"CONTENTS" (sometimes more than once, even if only one page),
"prop2" (sometimes more than once),
"prop3" (somtimes more than once), "DICT", "Summary Information",
"Owner" / "bryan". There might be some random stuff in there too.
Also appears to be a consistent bit of stuff "AuvsxjatP0udlw1Aaq5eubr5h" (t=
his
might not be ASCII though - there is a 0x05 0x00 always on the front of it.


--Boundary-01=_OUaSEnKK6JHfLjf
Content-Type: text/x-diff; charset="us-ascii";
	name="tiffmdi-snapshot-2006-04-22.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="tiffmdi-snapshot-2006-04-22.patch"

? autom4te.cache
? rects.txt
? tiffmdi-snapshot-2006-04-22.patch
? libtiff/tif_mdi.c
Index: libtiff/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/Makefile.am,v
retrieving revision 1.21
diff -u -4 -p -r1.21 Makefile.am
=2D-- libtiff/Makefile.am	21 Apr 2006 14:18:54 -0000	1.21
+++ libtiff/Makefile.am	22 Apr 2006 04:16:56 -0000
@@ -70,8 +70,9 @@ SRCS =3D \
 	tif_getimage.c \
 	tif_jpeg.c \
 	tif_luv.c \
 	tif_lzw.c \
+	tif_mdi.c \
 	tif_next.c \
 	tif_ojpeg.c \
 	tif_open.c \
 	tif_packbits.c \
Index: libtiff/tif_codec.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_codec.c,v
retrieving revision 1.10
diff -u -4 -p -r1.10 tif_codec.c
=2D-- libtiff/tif_codec.c	21 Dec 2005 12:23:13 -0000	1.10
+++ libtiff/tif_codec.c	22 Apr 2006 04:16:56 -0000
@@ -68,8 +68,11 @@ static	int NotConfigured(TIFF*, int);
 #endif
 #ifndef LOGLUV_SUPPORT
 #define TIFFInitSGILog		NotConfigured
 #endif
+#ifndef MDI_SUPPORT
+#define TIFFInitMDI		NotConfigured
+#endif
=20
 /*
  * Compression schemes statically built into the library.
  */
@@ -94,8 +97,12 @@ TIFFCodec _TIFFBuiltinCODECS[] =3D {
     { "AdobeDeflate",   COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },=20
     { "PixarLog",	COMPRESSION_PIXARLOG,	TIFFInitPixarLog },
     { "SGILog",		COMPRESSION_SGILOG,	TIFFInitSGILog },
     { "SGILog24",	COMPRESSION_SGILOG24,	TIFFInitSGILog },
+    /* TODO - add proper decompression for these */
+    { "MODI BW",	COMPRESSION_MODI_BLC,	TIFFInitMDI },
+    { "MODI Colour",	COMPRESSION_MODI_PTC,	TIFFInitMDI },
+    { "MODI Vector",	COMPRESSION_MODI_VECTOR, TIFFInitMDI },
     { NULL,             0,                      NULL }
 };
=20
 static int
Index: libtiff/tif_dirinfo.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirinfo.c,v
retrieving revision 1.62
diff -u -4 -p -r1.62 tif_dirinfo.c
=2D-- libtiff/tif_dirinfo.c	7 Feb 2006 10:45:38 -0000	1.62
+++ libtiff/tif_dirinfo.c	22 Apr 2006 04:16:57 -0000
@@ -268,8 +268,16 @@ tiffFieldInfo[] =3D {
     { TIFFTAG_STONITS,		 1, 1,	TIFF_DOUBLE,	FIELD_CUSTOM,
       0,	0,	"StoNits" },
     { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_LONG,	FIELD_CUSTOM,
       0,	0,	"InteroperabilityIFDOffset" },
+    { TIFFTAG_MDIOCRTEXT,    -1, -1,   TIFF_UNDEFINED,  FIELD_CUSTOM,
+      0,        0,  "TextContentsMDI" },
+/* MDI tag for document level metadata? */
+    { TIFFTAG_MDIMETADATA,    -1, -1, TIFF_UNDEFINED,   FIELD_CUSTOM,
+      0,        0,  "MDIMetaData" },
+/* MDI tag for page thumbnail? */
+    { TIFFTAG_MDITHUMBNAIL,  -1, -1,  TIFF_UNDEFINED,   FIELD_CUSTOM,
+      0,        0,  "MDIMetaData" },
 /* begin DNG tags */
     { TIFFTAG_DNGVERSION,	4, 4,	TIFF_BYTE,	FIELD_CUSTOM,=20
       0,	0,	"DNGVersion" },
     { TIFFTAG_DNGBACKWARDVERSION, 4, 4,	TIFF_BYTE,	FIELD_CUSTOM,=20
Index: libtiff/tif_dirread.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v
retrieving revision 1.84
diff -u -4 -p -r1.84 tif_dirread.c
=2D-- libtiff/tif_dirread.c	4 Apr 2006 02:00:08 -0000	1.84
+++ libtiff/tif_dirread.c	22 Apr 2006 04:16:57 -0000
@@ -29,8 +29,9 @@
  *
  * Directory Read Support Routines.
  */
 #include "tiffiop.h"
+#include "ctype.h"
=20
 #define	IGNORE	0		/* tag placeholder used below */
=20
 #ifdef HAVE_IEEEFP
@@ -61,8 +62,9 @@ static	int TIFFFetchDoubleArray(TIFF*, T
 static	int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*);
 static	int TIFFFetchShortPair(TIFF*, TIFFDirEntry*);
 static	void ChopUpSingleUncompressedStrip(TIFF*);
=20
+static int globalcount =3D 0;
 /*
  * Read the next TIFF directory from a file
  * and convert it to the internal format.
  * We read directories sequentially.
@@ -559,8 +561,125 @@ TIFFReadDirectory(TIFF* tif)
 			if (v)
 				TIFFSetField(tif, TIFFTAG_SUBFILETYPE, v);
 			break;
 /* END REV 4.0 COMPATIBILITY */
+		case TIFFTAG_MDIOCRTEXT:
+			{
+				unsigned char buf[4096];
+				tsize_t ret;
+				int lv;
+				unsigned int apparentLen;
+				ret =3D TIFFFetchData(tif, dp, buf);
+				if ((buf[0] !=3D 0x01) ||
+				    (buf[1] !=3D 0x00)) {
+					printf("sanity check1 failure\n");
+				}
+
+				apparentLen =3D buf[2] + (buf[3]<<8) +
+					(buf[4]<<16) + (buf[5]<<24);
+				if ( (ret - 6) !=3D apparentLen) {
+					printf("sanity check2 failure\n");
+				}
+
+				if ((buf[ret-1] !=3D 0x00) ||
+				    (buf[ret-2] !=3D 0x0d)) {
+					printf("sanity check3 failure\n");
+				}
+
+				for (lv =3D 6; lv < (ret-2); ++lv) {
+					if (isprint(buf[lv])) {
+						printf("%c", buf[lv]);
+					} else if (buf[lv] =3D=3D 0x0a){
+						printf("\n");
+					} else if (0xe2 =3D=3D buf[lv]) {
+						++lv;
+						if (0x80 =3D=3D buf[lv]) {
+							// this is some kind of character
+							++lv;
+							if (0x99 =3D=3D buf[lv]) {
+								printf("'");
+							} else if (0x9c =3D=3D buf[lv]) {
+								// left smartquotes
+								printf("\"");
+							} else if (0x9d =3D=3D buf[lv]) {
+								// right smartquotes
+								printf("\"");
+							} else if (0x93 =3D=3D buf[lv]) {
+								// long-dash
+								printf("-");
+							} else if (0x94 =3D=3D buf[lv]) {
+								// Unknown
+								printf("?");
+							} else if (0xa6 =3D=3D buf[lv]) {
+								// Unknown
+								printf("?");
+							} else {
+								printf("**** 0x%02x *****", buf[lv]);
+							}
+						}
+					} else if (0xc3 =3D=3D buf[lv]) {
+						++lv;
+						if (0xa9 =3D=3D buf[lv]) {
+							// e with grave
+							printf("e");
+						} else {
+							printf(" !0x%02x ! ", buf[lv]);
+						}
+					} else if (0xef =3D=3D buf[lv]) {
+						++lv;
+						if (0x82 =3D=3D buf[lv]) {
+							++lv;
+							if (0xa7 =3D=3D buf[lv]) {
+								// some kind of bullet?
+								printf("*");
+							} else if (0xb7 =3D=3D buf[lv]) {
+								// some kind of bullet?
+								printf("*");
+							} else {
+								printf("<0x%02x>", buf[lv]);
+							}
+						} else {
+							printf(">0x%02x<", buf[lv]);
+						}
+					} else {
+						printf(" 0x%02x ", buf[lv]);
+					}
+				}
+				TIFFSetField(tif, TIFFTAG_MDIOCRTEXT, "hello");
+			}
+			break;
+#if 0
+		case TIFFTAG_MDIMETADATA:
+			printf("found MDI metadata\n");
+			break;
+		case TIFFTAG_MDITHUMBNAIL:
+			printf("found MDI thumbnail\n");
+			{
+				unsigned char buf[4096];
+				tsize_t ret;
+				int lv;
+				FILE *fp;
+				char filename[20];
+				ret =3D TIFFFetchData(tif, dp, buf);
+				printf("ret: %i (0x%04x)\n", ret, ret);
+				if ((buf[0] !=3D 0x02) ||
+				    (buf[1] !=3D 0x00)) {
+					printf("sanity check1 failure\n");
+				}
+
+				if ((buf[2] !=3D 0x00) ||
+				    (buf[3] !=3D 0x00)) {
+					printf("sanity check2 failure\n");
+				}
+				// No idea what the 4th and 5th bytes are
+				snprintf(filename, 20, "thumb%i.ico", globalcount);
+				++globalcount;
+				fp =3D fopen(filename, "w");
+				fwrite(buf+6, 1, ret-6, fp);
+				fclose(fp);
+			}
+			break;
+#endif
 		default:
 			(void) TIFFFetchNormalTag(tif, dp);
 			break;
 		}
Index: libtiff/tiff.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tiff.h,v
retrieving revision 1.42
diff -u -4 -p -r1.42 tiff.h
=2D-- libtiff/tiff.h	23 Dec 2005 15:10:45 -0000	1.42
+++ libtiff/tiff.h	22 Apr 2006 04:16:58 -0000
@@ -195,8 +195,12 @@ typedef	enum {
 #define	    COMPRESSION_JBIG		34661	/* ISO JBIG */
 #define     COMPRESSION_SGILOG		34676	/* SGI Log Luminance RLE */
 #define     COMPRESSION_SGILOG24	34677	/* SGI Log 24-bit packed */
 #define     COMPRESSION_JP2000          34712   /* Leadtools JPEG2000 */
+/* these have been seen in Microsoft documentation for the MDI variant */
+#define     COMPRESSION_MODI_BLC        34718   /* Binary Level Codec */
+#define     COMPRESSION_MODI_PTC        34720
+#define     COMPRESSION_MODI_VECTOR     34719
 #define	TIFFTAG_PHOTOMETRIC		262	/* photometric interpretation */
 #define	    PHOTOMETRIC_MINISWHITE	0	/* min value is white */
 #define	    PHOTOMETRIC_MINISBLACK	1	/* min value is black */
 #define	    PHOTOMETRIC_RGB		2	/* RGB color model */
@@ -425,8 +429,12 @@ typedef	enum {
 /* tags 37439-37443 are registered to SGI <gregl@sgi.com> */
 #define TIFFTAG_STONITS			37439	/* Sample value to Nits */
 /* tag 34929 is a private tag registered to FedEx */
 #define	TIFFTAG_FEDEX_EDR		34929	/* unknown use */
+#define TIFFTAG_MDIOCRTEXT              37679
+#define TIFFTAG_MDIMETADATA             37680
+#define TIFFTAG_MDITHUMBNAIL            37681
+
 #define TIFFTAG_INTEROPERABILITYIFD	40965	/* Pointer to Interoperability p=
rivate directory */
 /* Adobe Digital Negative (DNG) format tags */
 #define TIFFTAG_DNGVERSION		50706	/* &DNG version number */
 #define TIFFTAG_DNGBACKWARDVERSION	50707	/* &DNG compatibility version */
Index: libtiff/tiffiop.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tiffiop.h,v
retrieving revision 1.47
diff -u -4 -p -r1.47 tiffiop.h
=2D-- libtiff/tiffiop.h	25 Mar 2006 03:09:24 -0000	1.47
+++ libtiff/tiffiop.h	22 Apr 2006 04:16:58 -0000
@@ -310,8 +310,11 @@ extern	int TIFFInitPixarLog(TIFF*, int);
 #endif
 #ifdef LOGLUV_SUPPORT
 extern	int TIFFInitSGILog(TIFF*, int);
 #endif
+#ifdef MDI_SUPPORT
+  extern int TIFFInitMDI(TIFF*, int);
+#endif
 #ifdef VMS
 extern	const TIFFCodec _TIFFBuiltinCODECS[];
 #else
 extern	TIFFCodec _TIFFBuiltinCODECS[];

--Boundary-01=_OUaSEnKK6JHfLjf
Content-Type: text/x-csrc;
  charset="us-ascii";
  name="tif_mdi.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="tif_mdi.c"

/*
 * Copyright (c) Brad Hards <bradh@frogmouth.net>
 *
 * Permission to use, copy, modify, distribute, and sell this software and=
=20
 * its documentation for any purpose is hereby granted without fee, provided
 * that the above copyright notices and this permission notice appear in
 * all copies of the software and related documentation.
 *=20
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,=20
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY=20
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. =20
 *=20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY O=
=46=20
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE=20
 * OF THIS SOFTWARE.
 */

#include "tiffiop.h"
#ifdef MDI_SUPPORT

/*
 * TIFF Library.
 *
 * MDI Image Support
 *
 */
static int
MDISetupDecode(TIFF* tif)
{
    return (1);
}

/*
 * Setup state for decoding a strip.
 */
static int
MDIPreDecode(TIFF* tif, tsample_t s)
{
    return 1;
}

static int
MDIDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
{
    int lv;
    printf("decode size: %i (%i)\n", occ, 2480*3508*3);
    printf("char count: %i\n", tif->tif_rawcc);
    for (lv =3D 0; lv < tif->tif_rawcc; ++lv) {
	printf("%02x ", tif->tif_rawcp[lv]);
    }
    printf("\n");
    return 0;
}

static int
MDISetupEncode(TIFF* tif)
{
    return 0;
}

/*
 * Reset encoding state at the start of a strip.
 */
static int
MDIPreEncode(TIFF* tif, tsample_t s)
{
    return 0;
}

/*
 * Encode a chunk of pixels.
 */
static int
MDIEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
{
    return (1);
}

/*
 * Finish off an encoded strip by flushing the last
 * string and tacking on an End Of Information code.
 */
static int
MDIPostEncode(TIFF* tif)
{
    return 1;
}

static void
MDICleanup(TIFF* tif)
{
}

int
TIFFInitMDI(TIFF* tif, int scheme)
{
	assert( (scheme =3D=3D COMPRESSION_MODI_BLC)
		|| (scheme =3D=3D COMPRESSION_MODI_VECTOR)
		|| (scheme =3D=3D COMPRESSION_MODI_PTC)
		);

	// printf("Init MDI\n");

	/*
	 * Install codec methods.
	 */
	tif->tif_setupdecode =3D MDISetupDecode;
	tif->tif_predecode =3D MDIPreDecode;
	tif->tif_decoderow =3D MDIDecode;
	tif->tif_decodestrip =3D MDIDecode;
	tif->tif_decodetile =3D MDIDecode;
	tif->tif_setupencode =3D MDISetupEncode;
	tif->tif_preencode =3D MDIPreEncode;
	tif->tif_postencode =3D MDIPostEncode;
	tif->tif_encoderow =3D MDIEncode;
	tif->tif_encodestrip =3D MDIEncode;
	tif->tif_encodetile =3D MDIEncode;
	tif->tif_cleanup =3D MDICleanup;
}
#endif



--Boundary-01=_OUaSEnKK6JHfLjf--

--nextPart6105240.OAhjMMNYYz
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBESaUSGwwszQ/PZzgRApQDAJ9Nsi4pnmKrmIrl7kpnvrP94CzdOwCdHQp2
+NiG5q1+F6eBDckGQIK5GUA=
=L9so
-----END PGP SIGNATURE-----

--nextPart6105240.OAhjMMNYYz--

--===============1539176979==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
--===============1539176979==--
