BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What library do I need to open a TIFF file

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Todd Cary
Guest





PostPosted: Mon Nov 29, 2004 11:51 pm    Post subject: What library do I need to open a TIFF file Reply with quote



I want to create a TBitMap from a LoadFromFile using a TIFF file. What
library to I need in order to do this?

Todd
Back to top
Nils Haeck
Guest





PostPosted: Tue Nov 30, 2004 12:24 am    Post subject: Re: What library do I need to open a TIFF file Reply with quote



You can try:
http://www.awaresystems.be/imaging/tiff/delphi.html

Kind regards,

Nils Haeck
www.simdesign.nl

"Todd Cary" <todd (AT) aristesoftware (DOT) com> wrote

Quote:
I want to create a TBitMap from a LoadFromFile using a TIFF file. What
library to I need in order to do this?

Todd



Back to top
Joris Van Damme
Guest





PostPosted: Tue Nov 30, 2004 9:55 am    Post subject: Re: What library do I need to open a TIFF file Reply with quote



"Nils Haeck" <n.haeckno (AT) spamchello (DOT) nl> wrote

Quote:
You can try:
http://www.awaresystems.be/imaging/tiff/delphi.html


Thank you for your kind link, Nils.

Yes, this pre-compiled LibTiff for Delphi can assist in e.g. loading a TIFF
file into a TBitmap. It's not the easiest library to use, and it's portable
instead of being rooted in Delphi VCL. But I plan to add a good deal of
Delphi specific information on its use in a little while.

Meanwhile, the C oriented documentation should do nicely. Especially note:

** General 'using LibTiff' stuff:
http://www.remotesensing.org/libtiff/libtiff.html
** Man pages on LibTiff functions:
http://www.remotesensing.org/libtiff/man/index.html
** LibTiff tutorial:
http://www-106.ibm.com/developerworks/linux/library/l-libtiff/
http://www-106.ibm.com/developerworks/linux/library/l-libtiff2/
** The LibTiffDelphi.pas unit, for declarations

For loading a TIFF into a TBitmap, something along these lines could be a
quick and easy solution (not a free lunch, returns always 32bit RGBA, even
when source is e.g. singlebit black and white):

procedure TIFFReadRGBAImageSwapRB(Width,Height: Cardinal; Memory: Pointer);
{$IFDEF DELPHI_5}
type
PCardinal = ^Cardinal;
{$ENDIF}
var
m: PCardinal;
n: Cardinal;
o: Cardinal;
begin
m:=Memory;
for n:=0 to Width*Height-1 do
begin
o:=m^;
m^:= (o and $FF00FF00) or
((o and $00FF0000) shr 16) or
((o and $000000FF) shl 16);
Inc(m);
end;
end;

function LoadTiffIntoBitmap(const Filename: String): TBitmap;
var
OpenTiff: PTIFF;
FirstPageWidth,FirstPageHeight: Cardinal;
FirstPageBitmap: TBitmap;
begin
OpenTiff:=TIFFOpen(Filename,'r');
TIFFGetField(OpenTiff,TIFFTAG_IMAGEWIDTH,@FirstPageWidth);
TIFFGetField(OpenTiff,TIFFTAG_IMAGELENGTH,@FirstPageHeight);
FirstPageBitmap:=TBitmap.Create;
FirstPageBitmap.PixelFormat:=pf32bit;
FirstPageBitmap.Width:=FirstPageWidth;
FirstPageBitmap.Height:=FirstPageHeight;
TIFFReadRGBAImage(OpenTiff,FirstPageWidth,FirstPageHeight,
FirstPageBitmap.Scanline[FirstPageHeight-1],0);
TIFFClose(OpenTiff);
TIFFReadRGBAImageSwapRB(FirstPageWidth,FirstPageheight,
FirstPageBitmap.Scanline[FirstPageHeight-1]);
Result:=FirstPageBitmap;
end;




Joris Van Damme
[email]info (AT) awaresystems (DOT) be[/email]
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html




Back to top
Todd Cary
Guest





PostPosted: Tue Nov 30, 2004 4:19 pm    Post subject: Re: What library do I need to open a TIFF file Reply with quote


Joris Van Damme wrote:

Quote:
"Nils Haeck" <n.haeckno (AT) spamchello (DOT) nl> wrote in message
news:41abbafc$1 (AT) newsgroups (DOT) borland.com...

You can try:
http://www.awaresystems.be/imaging/tiff/delphi.html



Thank you for your kind link, Nils.

Yes, this pre-compiled LibTiff for Delphi can assist in e.g. loading a TIFF
file into a TBitmap. It's not the easiest library to use, and it's portable
instead of being rooted in Delphi VCL. But I plan to add a good deal of
Delphi specific information on its use in a little while.

Meanwhile, the C oriented documentation should do nicely. Especially note:

** General 'using LibTiff' stuff:
http://www.remotesensing.org/libtiff/libtiff.html
** Man pages on LibTiff functions:
http://www.remotesensing.org/libtiff/man/index.html
** LibTiff tutorial:
http://www-106.ibm.com/developerworks/linux/library/l-libtiff/
http://www-106.ibm.com/developerworks/linux/library/l-libtiff2/
** The LibTiffDelphi.pas unit, for declarations

For loading a TIFF into a TBitmap, something along these lines could be a
quick and easy solution (not a free lunch, returns always 32bit RGBA, even
when source is e.g. singlebit black and white):

procedure TIFFReadRGBAImageSwapRB(Width,Height: Cardinal; Memory: Pointer);
{$IFDEF DELPHI_5}
type
PCardinal = ^Cardinal;
{$ENDIF}
var
m: PCardinal;
n: Cardinal;
o: Cardinal;
begin
m:=Memory;
for n:=0 to Width*Height-1 do
begin
o:=m^;
m^:= (o and $FF00FF00) or
((o and $00FF0000) shr 16) or
((o and $000000FF) shl 16);
Inc(m);
end;
end;

function LoadTiffIntoBitmap(const Filename: String): TBitmap;
var
OpenTiff: PTIFF;
FirstPageWidth,FirstPageHeight: Cardinal;
FirstPageBitmap: TBitmap;
begin
OpenTiff:=TIFFOpen(Filename,'r');
TIFFGetField(OpenTiff,TIFFTAG_IMAGEWIDTH,@FirstPageWidth);
TIFFGetField(OpenTiff,TIFFTAG_IMAGELENGTH,@FirstPageHeight);
FirstPageBitmap:=TBitmap.Create;
FirstPageBitmap.PixelFormat:=pf32bit;
FirstPageBitmap.Width:=FirstPageWidth;
FirstPageBitmap.Height:=FirstPageHeight;
TIFFReadRGBAImage(OpenTiff,FirstPageWidth,FirstPageHeight,
FirstPageBitmap.Scanline[FirstPageHeight-1],0);
TIFFClose(OpenTiff);
TIFFReadRGBAImageSwapRB(FirstPageWidth,FirstPageheight,
FirstPageBitmap.Scanline[FirstPageHeight-1]);
Result:=FirstPageBitmap;
end;




Joris Van Damme
[email]info (AT) awaresystems (DOT) be[/email]
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html




Thank you for your detailed response. I have been using the library
that came with a commercial program I bought (Envision), however, I
would like to have a more generic version of my application.

Todd Cary

Back to top
Ed Vander Hoek
Guest





PostPosted: Tue Nov 30, 2004 5:53 pm    Post subject: Re: What library do I need to open a TIFF file Reply with quote

Todd Cary wrote:
Quote:
I want to create a TBitMap from a LoadFromFile using a TIFF file. What
library to I need in order to do this?

Mike Lischke's open source GraphicEx can be found at
http://www.lischke-online.de. It supports reading Tiff, Png, Gif and a
number of other less common formats. It generally isn't able to write
these formats.

There's also http://www.simdesign.nl/components/imagemagick.html which
is a Delphi wrapper around the cross-platform ImageMagick library (found
at http://studio.imagemagick.org/index.html) which can read/write 90
different formats according to their website.

http://www.hicomponents.com has a commercial library called DImageEn
which has good support for tiff.

HTH,

Ed Vander Hoek

Back to top
Joris Van Damme
Guest





PostPosted: Tue Nov 30, 2004 11:53 pm    Post subject: Re: What library do I need to open a TIFF file Reply with quote

Quote:
Thank you for your detailed response. I have been using the library
that came with a commercial program I bought (Envision), however, I
would like to have a more generic version of my application.

What exactly do you mean by generic?

LibTiff is a portable library, designed to work acros just about all
possible platforms. It's been around for over a decade, has been maintained
and improved all that time. It's consider *the* TIFF library. It also has
excellent, independent support, firmly rooted in the open source tradition,
by means of a mailing list.

LibTiffDelphi (http://www.awaresystems.be/imaging/tiff/delphi.html) is a
pre-compiled version of LibTiff, without the need for a DLL or such (it is a
series of .obj files that link into your Delphi project at compile time, as
if they were native pascal), and without any dependency on any imaging
library or such (or even any runtime library, or even VCL, for that matter).
It does depend on ZLib and LibJpeg, but suitable pre-compiled versions of
these libraries are included in LibTiffDelphi, in the same .obj compile-time
linking way, so you needn't even be aware of this dependency.

Is any or all of this what you mean by 'generic'?


Joris Van Damme
[email]info (AT) awaresystems (DOT) be[/email]
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html





Back to top
Todd Cary
Guest





PostPosted: Wed Dec 01, 2004 12:28 am    Post subject: Re: What library do I need to open a TIFF file Reply with quote



Joris Van Damme wrote:
Quote:
"Nils Haeck" <n.haeckno (AT) spamchello (DOT) nl> wrote in message
news:41abbafc$1 (AT) newsgroups (DOT) borland.com...

You can try:
http://www.awaresystems.be/imaging/tiff/delphi.html



Thank you for your kind link, Nils.

Yes, this pre-compiled LibTiff for Delphi can assist in e.g. loading a TIFF
file into a TBitmap. It's not the easiest library to use, and it's portable
instead of being rooted in Delphi VCL. But I plan to add a good deal of
Delphi specific information on its use in a little while.

Meanwhile, the C oriented documentation should do nicely. Especially note:

** General 'using LibTiff' stuff:
http://www.remotesensing.org/libtiff/libtiff.html
** Man pages on LibTiff functions:
http://www.remotesensing.org/libtiff/man/index.html
** LibTiff tutorial:
http://www-106.ibm.com/developerworks/linux/library/l-libtiff/
http://www-106.ibm.com/developerworks/linux/library/l-libtiff2/
** The LibTiffDelphi.pas unit, for declarations

For loading a TIFF into a TBitmap, something along these lines could be a
quick and easy solution (not a free lunch, returns always 32bit RGBA, even
when source is e.g. singlebit black and white):

procedure TIFFReadRGBAImageSwapRB(Width,Height: Cardinal; Memory: Pointer);
{$IFDEF DELPHI_5}
type
PCardinal = ^Cardinal;
{$ENDIF}
var
m: PCardinal;
n: Cardinal;
o: Cardinal;
begin
m:=Memory;
for n:=0 to Width*Height-1 do
begin
o:=m^;
m^:= (o and $FF00FF00) or
((o and $00FF0000) shr 16) or
((o and $000000FF) shl 16);
Inc(m);
end;
end;

function LoadTiffIntoBitmap(const Filename: String): TBitmap;
var
OpenTiff: PTIFF;
FirstPageWidth,FirstPageHeight: Cardinal;
FirstPageBitmap: TBitmap;
begin
OpenTiff:=TIFFOpen(Filename,'r');
TIFFGetField(OpenTiff,TIFFTAG_IMAGEWIDTH,@FirstPageWidth);
TIFFGetField(OpenTiff,TIFFTAG_IMAGELENGTH,@FirstPageHeight);
FirstPageBitmap:=TBitmap.Create;
FirstPageBitmap.PixelFormat:=pf32bit;
FirstPageBitmap.Width:=FirstPageWidth;
FirstPageBitmap.Height:=FirstPageHeight;
TIFFReadRGBAImage(OpenTiff,FirstPageWidth,FirstPageHeight,
FirstPageBitmap.Scanline[FirstPageHeight-1],0);
TIFFClose(OpenTiff);
TIFFReadRGBAImageSwapRB(FirstPageWidth,FirstPageheight,
FirstPageBitmap.Scanline[FirstPageHeight-1]);
Result:=FirstPageBitmap;
end;




Joris Van Damme
[email]info (AT) awaresystems (DOT) be[/email]
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html




Well, you got me on two items: incorrect use of the word "generic" and
my not knowing about LibTiff. Not a good batting average - 0/2!

1) I want to use a library that is widely available.

2) My exposure to graphic manipulation has been minimal and I did not
know about LibTiff. I am glad that I came upon it. It will be used
with Graphic32.

Thank you for setting me straight!

Todd

Back to top
Joris Van Damme
Guest





PostPosted: Wed Dec 01, 2004 3:17 am    Post subject: Re: What library do I need to open a TIFF file Reply with quote

"Todd Cary" <todd (AT) aristesoftware (DOT) com> wrote

Quote:
Thank you for setting me straight!

Todd,

It wasn't so much my intention to 'set you straight', but instead to inform.
I'm happy to be of service.

Quote:
It will be used with Graphic32

In that case, the main disadvantage of using LibTiff's easiest interface,
TIFFReadRGBAImage, being that it always returns 32bit RGBA, actually becomes
an advantage, as Graphics32 only handles that particular colorspace and
bitdepth.

I'd like to invite you to keep me posted on [email]info (AT) awaresystems (DOT) be[/email]. LibTiff is
ancient and like *the* library, but the pre-compiled LibTiffDelphi is
relatively new, and I would appreciate your feedback on your glueing it to
Graphics32. [email]info (AT) awaresystems (DOT) be[/email] is also the address to use if you have
suggestions, or questions that aren't covered by the LibTiff documentation
that I mentioned in an earlier mail, and that are too Delphi specific to be
asked in the LibTiff mailing list.

I also recommend using the 'update notification' service on the download
page http://www.awaresystems.be/imaging/tiff/delphi.html. If you do that (by
using any 'drop us a line' mail-link), you'll be kept informed about any
newer versions and/or major documentation updates.


Joris Van Damme
[email]info (AT) awaresystems (DOT) be[/email]
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.