Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas025.isp.belgacom.be (localhost [127.0.0.1])
        by inav006.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id j85Hp2Qn000337
        for <joris.at.lebbeke@skynet.be>; Mon, 5 Sep 2005 19:51:02 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx001.isp.belgacom.be (inmx001.isp.belgacom.be [195.238.2.1])
        by inas025.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id j85Hou6T013384
        for <joris.at.lebbeke@skynet.be>; Mon, 5 Sep 2005 19:50:57 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx001.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j85HoqnQ008250
        for <joris.at.lebbeke@skynet.be>; Mon, 5 Sep 2005 19:50:52 +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 j85HjHeQ024565;
	Mon, 5 Sep 2005 13:45:46 -0400
Received: from outmx018.isp.belgacom.be (outmx018.isp.belgacom.be
	[195.238.2.117])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j85HjEgY024562
	for <tiff@lists.maptools.org>; Mon, 5 Sep 2005 13:45:14 -0400
Received: from outmx018.isp.belgacom.be (localhost [127.0.0.1])
	by outmx018.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id j85HjBfE029011
	for <tiff@lists.maptools.org>; Mon, 5 Sep 2005 19:45:11 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (141-184.246.81.adsl.skynet.be [81.246.184.141])
	by outmx018.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id j85HjA9E029001; Mon, 5 Sep 2005 19:45:10 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <003001c5b241$96aa9ff0$8db8f651@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: "Stephen Billard" <stephen@sbillard.org>,
        "TIFF mailing list" <tiff@lists.maptools.org>
References: <001101c5b237$76fd8a00$7e00a8c0@stephen>
Subject: Re: [Tiff] LibTIFFDelphi and Delphi OpenPictureDialog
Date: Mon, 5 Sep 2005 19:45:19 +0200
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
Cc: 
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>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00000b94
X-MSP-STORE: Mon, 05 Sep 2005 19:51:08 +0200
Status:   

Stephen,

Stephen Billard wrote:
> Does anyone have an example of how to hook LibTIFFDelphi into the
> Delphi OpenPictureDialog component so that it will show TIFF images
> in the preview panel?

Please post only plain text messages to the list.

What you're asking for is quite something...

The standard OpenPictureDialog works with a TImage component. A TImage
works with a TPicture. A TPicture access the list of known TGraphic
classes to get a list of supported extensions, and build a particular
TGraphic that supports a particular file format.

Thus, for this to work, you'll have to build a TGraphicTiff sorts of
thing, that inherits from the TGraphic. This involves implementing all
virtual methods of TGraphic, and registring your descendant. Next, when
a TPicture is asked what file extensions it supports, it will include
the extensions added by the TGraphicTiff registration (or something,
this is all from the top of my head...), and when a TPicture is asked to
open a 'xxx.tif' file, it will know that it can create a TGraphicTiff
and delegate the actual opening and rendering to this TGraphicTiff.

The bad news is that this is a lot of work. The worst news, however, is
that the whole system is useless. Many TIFF files are quite large. In
the standard VCL system explained above, normally, message pump is
frozen while the complete image gets decoded and resized and rendered,
all in the main thread. This means that, if the user accesses a
directory with such large TIFFs, and riscs clicking one, he'll next have
to wait for seconds or more, before application starts responding again.
A user may very well prefer not previewing over halting his action for
seconds or more every time he clicks another file.

When the user next clicks 'open' on the dialog, its content isn't
actually destroyed (untill the OpenPictureDialog component on your
calling form is destroyed, or is used a next time). Your calling code
gets a filename only. Thus, the most likely action is that your calling
code opens again the same TIFF file, repeating all previous processing,
producing duplicate memory. This, too, adds to the whole system becoming
completely useless on anything but small sized images.

It is not impossible to work around this. In fact, I'm in the process of
building a much nicer, multi-thread TGraphic system on top of the
existing one. It's a lot of work though, and I don't expect it to become
avaibable any time sooner then 2006.

If you're nevertheless interested in using TGraphic the normal VCL way,
take a look at graphics.pas and jpeg.pas for clues on how to build your
TGraphicTiff. If you're unclear on the basics of TImage, TPicture, and
TGraphic, and how they interact,
http://www.awaresystems.be/techtalks/003_graphic_picture_image.html may
be helpful.


Kind regards,


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@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
