Return-Path: <tiff-bounces@remotesensing.org>
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx016.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j4PCsSIN018815
        for <joris.at.lebbeke@skynet.be>; Wed, 25 May 2005 14:54:31 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id 9394F259CDEA; Wed, 25 May 2005 08:53:52 -0400 (EDT)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from outmx021.isp.belgacom.be (outmx021.isp.belgacom.be
	[195.238.2.202])
	by xserve.flids.com (Postfix) with ESMTP id 7CE6E259CDB8
	for <tiff@remotesensing.org>; Wed, 25 May 2005 08:53:48 -0400 (EDT)
Received: from outmx021.isp.belgacom.be (localhost [127.0.0.1])
	by outmx021.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id j4PCrjW4026230
	for <tiff@remotesensing.org>; Wed, 25 May 2005 14:53:45 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (159-171.246.81.adsl.skynet.be [81.246.171.159])
	by outmx021.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id j4PCrfio026184; Wed, 25 May 2005 14:53:42 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <003501c56128$ed490960$9fabf651@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: "yourpattern" <yourpattern@126.com>, <tiff@remotesensing.org>
References: <42940484.00007B.10098@m52.126.com>
Subject: Re: [Tiff] Question about Jpeg-in-tiff,
	JPEG IN TIFF created by libtiff can't be read by acdsee
Date: Wed, 25 May 2005 14:30:13 +0200
MIME-Version: 1.0
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Cc: 
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 000000000023ceae.00000266
X-MSP-STORE: Wed, 25 May 2005 14:54:40 +0200
Status:   

> uint32 rowsperstrip = TIFFDefaultStripSize(m_tif, (uint32) -1);
TIFFSetField(m_tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);

This line, you might want to change, if you set out to write a single strip
TIFF. Set rowsperstrip to the pBitmapHeaderInfo->biHeight. That should cause the
TIFF to be written as a single strip.

> When i use TIFFSetField(m_tif, TIFFTAG_ROWSPERSTRIP, height);
> it seems the jpeg-data was writed as a single strip.but ACDSEE still can't
opened it.

Like Jean-Yves said, a tiffinfo or tiffdump or AsTiffTagViewer dump of the
offending file might help us identify the problem. It is of course entirely
possible the ACDSEE just sucks, of course, when it comes to jpeg-in-tiff, and
that none of us can do anything about that.

> Or is there another way could do it ?
> such as "Attach" & "Detach" the JPEG-data into(out of) TIFF file as a single
strip(or tile), without doing compress or decompress the image data.
> thus save the time & image quality ,is it possible ?

I've been thinking on and off about this, recently...

First important issue here, is that JPEG allows for some YCbCrSubsampling values
that TIFF does not like. So any scheme for direct transcoding from JPEG to
JPEG-in-TIFF, cannot possibly work for all possible JPEGs.

This being said, it should be possible for the vast majority, though. What I
would do, is something like this:

- start scanning the JPEG file up to the SOS marker. The markers you encounter
this way...
    - some, you might just want to ignore, like the SOI marker and unknown APP
markers
    - some identify the colorspace, some identify YCbCrSubsampling values, these
should be interpreted, and the results should be stored
    - some like DHT and DQT contain tables, the tables should be stored in temp
memory, too
- now start building the TIFF file. The previous stage should have yielded
proper values for ImageWidth, ImageLength, Photometric, YCbCrSubsampling, and
all needed tags.
- now start writing the compressed single strip
    - start with SOI marker
    - continue with the saved table markers, and the needed SOF and SOI marker
and such
    - append the rest of the JPEG file

> does anyone do some research on it ?

The above is only what I thought of doing, I never actually tried it. (Except
that I did succeed in decoding ojpeg files properly with a similar JPEG-stream
filtering/rebuilding scheme.) But if anyone wants to have a go at it, I'll be
all ears and eager to help if I can.



Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

_______________________________________________
Tiff mailing list: Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
