Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx-y.one.com (mx-y.one.com [195.47.247.150])
	by mail6.local (Postfix) with ESMTP id 07C9680193EEE
	for <filtered@awaresystems.be>; Wed,  5 Feb 2014 00:33:32 +0100 (CET)
X-Virus-Scanned: by one.com
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
Received-SPF: pass (mx-y: domain of awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates 209.85.217.169 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169])
	by mx-y.one.com (Postfix) with ESMTP id C51CC22024EAF
	for <filtered@awaresystems.be>; Tue,  4 Feb 2014 23:33:31 +0000 (UTC)
Received: by mail-lb0-f169.google.com with SMTP id q8so7132289lbi.0
        for <filtered@awaresystems.be>; Tue, 04 Feb 2014 15:33:31 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-original-authentication-results:delivered-to:delivered-to
         :message-id:from:to:date:importance:mime-version:subject:precedence
         :list-id:list-unsubscribe:list-archive:list-post:list-help
         :list-subscribe:content-type:mime-version:sender:errors-to;
        bh=vg3EpYLuFdmU4UkcKlf0bOkHWOPGnpIOlkTuWeVutgI=;
        b=J6DCLFYX4YtSK62Z0RhRTkFyW9udlT+5RKrtJC7aDMPIw6mphOK+9gunvGtJVmWYHU
         boeyEu5fYVbfAJdFSlKkPQbFfU7n9BH1JC6lOcK+1x/h20k/ymxZqANivrrIymwIimLz
         CaF59FOtvdXo2Fy+ZFLPiGmAoGaYpDpeCCxbyGc2O8iNiEom8rXYTh9DvYujjoOfIBtq
         Nj5zxaYlKibZ8Y5nfkxuESP0rZlycBP5/QrUBRgQsuDhRtknwSBFadijq5j/hgBqryDA
         fdJFuAdPV82w0u8/eKltr2ohNSAh4hklwwpFpaoMmcZncI68VisF1FYJwDsQ8XIS4Q1c
         Dh6g==
X-Original-Authentication-Results: mx.google.com;       spf=neutral (google.com: 195.47.247.72 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mail=tiff-bounces@lists.maptools.org
X-Received: by 10.152.170.232 with SMTP id ap8mr3598349lac.40.1391556811375;
        Tue, 04 Feb 2014 15:33:31 -0800 (PST)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.114.12.135 with SMTP id y7csp225369ldb;
        Tue, 4 Feb 2014 15:33:30 -0800 (PST)
X-Received: by 10.112.14.1 with SMTP id l1mr3701393lbc.39.1391556809444;
        Tue, 04 Feb 2014 15:33:29 -0800 (PST)
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 195.47.247.72 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mail=tiff-bounces@lists.maptools.org
Received-SPF: neutral (google.com: 195.47.247.72 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=195.47.247.72;
Received: by 10.112.34.235 with POP3 id c11mf3823646lbj.13;
        Tue, 04 Feb 2014 15:33:29 -0800 (PST)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110 info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx01.one.com (mx01.one.com [195.47.247.72])
	by mail6.local (Postfix) with ESMTP id CC80380193EE8
	for <info@awaresystems.be>; Wed,  5 Feb 2014 00:30:58 +0100 (CET)
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2
Received: from lists.maptools.org (ks365428.kimsufi.com [94.23.4.142])
	by mx01.one.com (Postfix) with ESMTP id 953E215085BE
	for <info@awaresystems.be>; Tue,  4 Feb 2014 23:30:58 +0000 (UTC)
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id DFFAB35C03E;
	Tue,  4 Feb 2014 18:30:14 -0500 (EST)
Received: from dub0-omc1-s7.dub0.hotmail.com (dub0-omc1-s7.dub0.hotmail.com
	[157.55.0.206])
	by lists.maptools.org (Postfix) with ESMTP id 5E61F35C038
	for <tiff@lists.maptools.org>; Tue,  4 Feb 2014 18:29:38 -0500 (EST)
Received: from DUB129-W17 ([157.55.0.238]) by dub0-omc1-s7.dub0.hotmail.com
	with Microsoft SMTPSVC(6.0.3790.4675); 
	Tue, 4 Feb 2014 15:29:38 -0800
X-TMN: [nfMPe5Dsp8iTkydnfIXGfj5+Gs/EzUxG]
X-Originating-Email: [array81@hotmail.com]
Message-ID: <DUB129-W17B197BE2F5DA19AA43135BFAA0@phx.gbl>
From: Martin Masci <array81@hotmail.com>
To: "tiff@lists.maptools.org" <tiff@lists.maptools.org>
Date: Wed, 5 Feb 2014 00:29:38 +0100
Importance: Normal
MIME-Version: 1.0
X-OriginalArrivalTime: 04 Feb 2014 23:29:38.0484 (UTC)
	FILETIME=[F8B2B740:01CF2200]
Subject: [Tiff] LibTiffDelphi and 1bit tiff
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
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="===============0539633450=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============0539633450==
Content-Type: multipart/alternative;
	boundary="_747d104d-8578-4eab-acb6-a0ae9edb13b4_"

--_747d104d-8578-4eab-acb6-a0ae9edb13b4_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi=2C
I'm using LibTiffDelphi to convert a bitmap image to 1bit tiff image.This i=
s my code:

var  OpenTiff: PTIFF=3B  RowSize: Longword=3B  RowsPerStrip: Longword=3B  S=
tripMemory: Pointer=3B  StripIndex: Longword=3B  StripRowOffset: Longword=
=3B  StripRowCount: Longword=3B  mb: PByte=3B  ny: Longword=3B  dpi: Double=
=3Bbegin  if (Bitmap.PixelFormat<>pf1bit) then    raise Exception.Create('W=
riteBitmapToTiff is designed for singlebit bitmaps only')=3B
  InvertRect(Bitmap.Canvas.Handle=2C Bitmap.Canvas.ClipRect)=3B  RowSize:=
=3D((Bitmap.Width+7) div 8)=3B  RowsPerStrip:=3D((256*1024) div RowSize)=3B
  if RowsPerStrip>Bitmap.Height then    RowsPerStrip:=3DBitmap.Height  else=
 if RowsPerStrip=3D0 then    RowsPerStrip:=3D1=3B
  StripMemory:=3DGetMemory(RowsPerStrip*RowSize)=3B  OpenTiff:=3DTIFFOpen(F=
ilename=2C'w')=3B
  if OpenTiff=3Dnil then    begin      FreeMemory(StripMemory)=3B      rais=
e Exception.Create('Unable to create file '''+Filename+'''')=3B    end=3B
  TIFFSetField(OpenTiff=2CTIFFTAG_IMAGEWIDTH=2CBitmap.Width)=3B  TIFFSetFie=
ld(OpenTiff=2CTIFFTAG_IMAGELENGTH=2CBitmap.Height)=3B  TIFFSetField(OpenTif=
f=2CTIFFTAG_PHOTOMETRIC=2CPHOTOMETRIC_MINISWHITE)=3B  TIFFSetField(OpenTiff=
=2CTIFFTAG_SAMPLESPERPIXEL=2C1)=3B  TIFFSetField(OpenTiff=2CTIFFTAG_BITSPER=
SAMPLE=2C1)=3B  TIFFSetField(OpenTiff=2CTIFFTAG_PLANARCONFIG=2CPLANARCONFIG=
_CONTIG)=3B  TIFFSetField(OpenTiff=2CTIFFTAG_COMPRESSION=2CCOMPRESSION_CCIT=
TFAX4)=3B
  // deve essere un double=2C se si usa un integer non funziona  dpi :=3D 2=
00=3B  TIFFSetField(OpenTiff=2CTIFFTAG_XRESOLUTION=2C dpi)=3B  TIFFSetField=
(OpenTiff=2CTIFFTAG_YRESOLUTION=2C dpi)=3B  TIFFSetField(OpenTiff=2CTIFFTAG=
_RESOLUTIONUNIT=2CRESUNIT_INCH)=3B  TIFFSetField(OpenTiff=2CTIFFTAG_ROWSPER=
STRIP=2CRowsPerStrip)=3B
  StripIndex:=3D0=3B  StripRowOffset:=3D0=3B  while StripRowOffset<Bitmap.H=
eight do    begin      StripRowCount:=3DRowsPerStrip=3B
      if StripRowCount>Bitmap.Height-StripRowOffset then        StripRowCou=
nt:=3DBitmap.Height-StripRowOffset=3B
      mb:=3DStripMemory=3B
      for ny:=3DStripRowOffset to StripRowOffset+StripRowCount-1 do        =
begin          CopyMemory(mb=2CBitmap.ScanLine[ny]=2CRowSize)=3B          I=
nc(mb=2CRowSize)=3B        end=3B
      if TIFFWriteEncodedStrip(OpenTiff=2CStripIndex=2C          StripMemor=
y=2CStripRowCount*RowSize)=3D-1 then        begin          TIFFClose(OpenTi=
ff)=3B          FreeMemory(StripMemory)=3B          raise Exception.Create(=
'Failed to write '''+Filename+'''')=3B        end=3B
      Inc(StripIndex)=3B      Inc(StripRowOffset=2CStripRowCount)=3B    end=
=3B
  TIFFClose(OpenTiff)=3B  FreeMem(StripMemory)=3Bend=3B

Now I need control threshold to change contrast. In FreeImage for example I=
 can use Threshold(Value) function to change threshold from 0 to 255 value.
How can I edit threshold with LibTiffDelphi?
Thanks 		 	   		  =

--_747d104d-8578-4eab-acb6-a0ae9edb13b4_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 12pt=3B
font-family:Calibri
}
--></style></head>
<body class=3D'hmmessage'><div dir=3D'ltr'>Hi=2C<div><br></div><div>I'm usi=
ng&nbsp=3BLibTiffDelphi to convert a bitmap image to 1bit tiff image.</div>=
<div>This is my code:</div><div><br></div><div><br></div><div><div>var</div=
><div>&nbsp=3B OpenTiff: PTIFF=3B</div><div>&nbsp=3B RowSize: Longword=3B</=
div><div>&nbsp=3B RowsPerStrip: Longword=3B</div><div>&nbsp=3B StripMemory:=
 Pointer=3B</div><div>&nbsp=3B StripIndex: Longword=3B</div><div>&nbsp=3B S=
tripRowOffset: Longword=3B</div><div>&nbsp=3B StripRowCount: Longword=3B</d=
iv><div>&nbsp=3B mb: PByte=3B</div><div>&nbsp=3B ny: Longword=3B</div><div>=
&nbsp=3B dpi: Double=3B</div><div>begin</div><div>&nbsp=3B if (Bitmap.Pixel=
Format&lt=3B&gt=3Bpf1bit) then</div><div>&nbsp=3B &nbsp=3B raise Exception.=
Create('WriteBitmapToTiff is designed for singlebit bitmaps only')=3B</div>=
<div><br></div><div>&nbsp=3B InvertRect(Bitmap.Canvas.Handle=2C Bitmap.Canv=
as.ClipRect)=3B</div><div>&nbsp=3B RowSize:=3D((Bitmap.Width+7) div 8)=3B</=
div><div>&nbsp=3B RowsPerStrip:=3D((256*1024) div RowSize)=3B</div><div><br=
></div><div>&nbsp=3B if RowsPerStrip&gt=3BBitmap.Height then</div><div>&nbs=
p=3B &nbsp=3B RowsPerStrip:=3DBitmap.Height</div><div>&nbsp=3B else if Rows=
PerStrip=3D0 then</div><div>&nbsp=3B &nbsp=3B RowsPerStrip:=3D1=3B</div><di=
v><br></div><div>&nbsp=3B StripMemory:=3DGetMemory(RowsPerStrip*RowSize)=3B=
</div><div>&nbsp=3B OpenTiff:=3DTIFFOpen(Filename=2C'w')=3B</div><div><br><=
/div><div>&nbsp=3B if OpenTiff=3Dnil then</div><div>&nbsp=3B &nbsp=3B begin=
</div><div>&nbsp=3B &nbsp=3B &nbsp=3B FreeMemory(StripMemory)=3B</div><div>=
&nbsp=3B &nbsp=3B &nbsp=3B raise Exception.Create('Unable to create file ''=
'+Filename+'''')=3B</div><div>&nbsp=3B &nbsp=3B end=3B</div><div><br></div>=
<div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTAG_IMAGEWIDTH=2CBitmap.Width)=3B=
</div><div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTAG_IMAGELENGTH=2CBitmap.He=
ight)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTAG_PHOTOMETRIC=2CP=
HOTOMETRIC_MINISWHITE)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTA=
G_SAMPLESPERPIXEL=2C1)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTA=
G_BITSPERSAMPLE=2C1)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=2CTIFFTAG_=
PLANARCONFIG=2CPLANARCONFIG_CONTIG)=3B</div><div>&nbsp=3B TIFFSetField(Open=
Tiff=2CTIFFTAG_COMPRESSION=2CCOMPRESSION_CCITTFAX4)=3B</div><div><br></div>=
<div>&nbsp=3B // deve essere un double=2C se si usa un integer non funziona=
</div><div>&nbsp=3B dpi :=3D 200=3B</div><div>&nbsp=3B TIFFSetField(OpenTif=
f=2CTIFFTAG_XRESOLUTION=2C dpi)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=
=2CTIFFTAG_YRESOLUTION=2C dpi)=3B</div><div>&nbsp=3B TIFFSetField(OpenTiff=
=2CTIFFTAG_RESOLUTIONUNIT=2CRESUNIT_INCH)=3B</div><div>&nbsp=3B TIFFSetFiel=
d(OpenTiff=2CTIFFTAG_ROWSPERSTRIP=2CRowsPerStrip)=3B</div><div><br></div><d=
iv>&nbsp=3B StripIndex:=3D0=3B</div><div>&nbsp=3B StripRowOffset:=3D0=3B</d=
iv><div>&nbsp=3B while StripRowOffset&lt=3BBitmap.Height do</div><div>&nbsp=
=3B &nbsp=3B begin</div><div>&nbsp=3B &nbsp=3B &nbsp=3B StripRowCount:=3DRo=
wsPerStrip=3B</div><div><br></div><div>&nbsp=3B &nbsp=3B &nbsp=3B if StripR=
owCount&gt=3BBitmap.Height-StripRowOffset then</div><div>&nbsp=3B &nbsp=3B =
&nbsp=3B &nbsp=3B StripRowCount:=3DBitmap.Height-StripRowOffset=3B</div><di=
v><br></div><div>&nbsp=3B &nbsp=3B &nbsp=3B mb:=3DStripMemory=3B</div><div>=
<br></div><div>&nbsp=3B &nbsp=3B &nbsp=3B for ny:=3DStripRowOffset to Strip=
RowOffset+StripRowCount-1 do</div><div>&nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B =
begin</div><div>&nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B CopyMemory(mb=
=2CBitmap.ScanLine[ny]=2CRowSize)=3B</div><div>&nbsp=3B &nbsp=3B &nbsp=3B &=
nbsp=3B &nbsp=3B Inc(mb=2CRowSize)=3B</div><div>&nbsp=3B &nbsp=3B &nbsp=3B =
&nbsp=3B end=3B</div><div><br></div><div>&nbsp=3B &nbsp=3B &nbsp=3B if TIFF=
WriteEncodedStrip(OpenTiff=2CStripIndex=2C</div><div>&nbsp=3B &nbsp=3B &nbs=
p=3B &nbsp=3B &nbsp=3B StripMemory=2CStripRowCount*RowSize)=3D-1 then</div>=
<div>&nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B begin</div><div>&nbsp=3B &nbsp=3B =
&nbsp=3B &nbsp=3B &nbsp=3B TIFFClose(OpenTiff)=3B</div><div>&nbsp=3B &nbsp=
=3B &nbsp=3B &nbsp=3B &nbsp=3B FreeMemory(StripMemory)=3B</div><div>&nbsp=
=3B &nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B raise Exception.Create('Failed to w=
rite '''+Filename+'''')=3B</div><div>&nbsp=3B &nbsp=3B &nbsp=3B &nbsp=3B en=
d=3B</div><div><br></div><div>&nbsp=3B &nbsp=3B &nbsp=3B Inc(StripIndex)=3B=
</div><div>&nbsp=3B &nbsp=3B &nbsp=3B Inc(StripRowOffset=2CStripRowCount)=
=3B</div><div>&nbsp=3B &nbsp=3B end=3B</div><div><br></div><div>&nbsp=3B TI=
FFClose(OpenTiff)=3B</div><div>&nbsp=3B FreeMem(StripMemory)=3B</div><div>e=
nd=3B</div></div><div><br></div><div><br></div><div>Now I need control thre=
shold to change contrast. In FreeImage for example I can use&nbsp=3BThresho=
ld(Value) function to change&nbsp=3B<span style=3D"font-size: 12pt=3B">thre=
shold from 0 to 255 value.</span></div><div><span style=3D"font-size: 12pt=
=3B"><br></span></div><div><span style=3D"font-size: 12pt=3B">How can I edi=
t t</span><span style=3D"font-size: 12pt=3B">hreshold with&nbsp=3B</span><s=
pan style=3D"font-size: 12pt=3B">LibTiffDelphi?</span></div><div><span styl=
e=3D"font-size: 12pt=3B"><br></span></div><div><span style=3D"font-size: 12=
pt=3B">Thanks</span></div> 		 	   		  </div></body>
</html>=

--_747d104d-8578-4eab-acb6-a0ae9edb13b4_--

--===============0539633450==
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/
--===============0539633450==--
