2006.05.05 17:02 "[Tiff] tiff split with delphi", by Andrea Bo
Hi all, I have try to traduce the tiffsplitt.c in Delphi, i have a problem in this function (C fun)
cpStrips(TIFF* in, TIFF* out)
{
tsize_t bufsize = TIFFStripSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
tstrip_t s, ns = TIFFNumberOfStrips(in);
uint32 *bytecounts;
TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
for (s = 0; s < ns; s++) {
if (bytecounts[s] > (uint32)bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]);
if (!buf)
return (0);
bufsize = bytecounts[s];
}
if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 ||
TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) {
_TIFFfree(buf);
return (0);
}
}
_TIFFfree(buf);
return (1);
}
return (0);
}
Traduce in delphi
procedure TForm1.cpStrips(OpenTiff, Outfile: PTiff);
var
bufsize: cardinal;
buf :^char;
ns: cardinal;
s: cardinal;
bytecounts: array of Integer;
begin
bufsize:= TIFFStripSize(OpenTiff);
buf:=_TIFFmalloc(bufsize);
if buf <> nil then
begin
ns:= TIFFNumberOfStrips(OpenTiff);
TIFFGetField(OpenTiff, TIFFTAG_STRIPBYTECOUNTS, @bytecounts);
for s:= 0 to ns do
begin
if (bytecounts[s]> bufsize) then /**this condition is never verified ***/
begin
buf := _TIFFrealloc(buf, bytecounts[s]);
if (buf)=nil then
begin
Exit;
bufsize:= bytecounts[s];
end;
if (TIFFReadRawStrip(OpenTiff, s, buf, bytecounts[s]) < 0 )or
(TIFFWriteRawStrip(Outfile, s, buf, bytecounts[s]) < 0) then
begin
_TIFFfree(buf);
Exit;
end;
end;
end;
_TIFFfree(buf);
Exit;
end;
Exit;
end;
I cant Write in output file.
thx Andrea
-------
Il presente messaggio di posta elettronica ed ogni documento allegato potrebbe avere carattere riservato ed � ad esclusivo utilizzo del destinatario indicato in indirizzo. Qualora non
foste il destinatario del presente messaggio, Vi preghiamo di non leggerlo e di avvertirci immediatamente tramite posta elettronica o telefonicamente e di cancellare il presente messaggio e
ogni documento ad esso allegato dal Vostro sistema. E� vietata la pubblicazione o l�utilizzo per qualunque fine del presente messaggio e di ogni documento ad esso allegato
cos� come la relativa divulgazione, distribuzione o inoltro a terzi senza l�espressa autorizzazione del mittente. Qualsiasi dato personale allegato o contenuto in questo
messaggio di posta elettronica � trattato, ai sensi del Dlgs. 196/2003 �Codice in materia di protezione dei dati personali�, secondo le disposizioni
dell�informativa predisposta da Interconsult S.r.l., copia della quale � accessibile al sito:
https://www.interconsult.it/ASP/main/Privacy.html
This e-mail and any file attached hereto may contain material that is confidential and for the sole use of the intended recipient. If you are not the intended recipient, please do not read it,
notify us immediately by e-mail or by telephone and delete this message and any file attached from your system. Any use, disclosure, forward, printing or copying of this email and its
attachments without express permission is strictly prohibited. Any personal data attached to or included in this email is being treated, pursuant to decree 196/2003 �Data Protection
Code�, in accordance with the provisions of the Interconsult S.r.l. Data Protection Policy, a copy of which is available on the following web site:
https://www.interconsult.it/ASP/main/en/Privacy.html