VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 123456[7]8910 ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 06:49:30 10/17/01 Wed
Author: Petko Penev
Subject: Invalid offset into the BLOB - AGAIN

Dear Sirs,
I have a problem with writing Tiff-files in Blob-fields. On the site - www.voy.com - I saw that other peoples have the same problem: (Date Posted: 11:05:04 08/05/01 Sun Author: Ruy Subject: Invalid offset into the BLOB), but from your answers it is not clearly how to resolve the problem. Those’s why I will ask you again and send you detailed examples of the problem code:
procedure TMain.aLoadShemaExecute(Sender: TObject);
var
Stream: TBlobStream;
begin
with OpenPictureDialog1 do
if Execute then
begin
ImageShema.Picture.LoadFromFile(FileName); // Only tiff files (ImageShema: TImage)

with DataModule1.tblTree do
begin
Edit;
Stream:=TBlobStream.Create(FieldByName('Picture') as TBlobField, bmWrite);
(ImageShema.Picture.Graphic as TTiffGraphic).SaveToStream(Stream); // Here raise the error

Post;
Stream.Free;
end;
end;
end;

In the code above, the following error is raised:
"Invalid offset into the Blob".The error is raised due the executing of TIFFClose(TiffHandle) in the procedure - EnTifGr.WriteDibToTiffStream.
That’s why I was forced to use the lower code, ho is working correctly.

procedure TMain.aLoadShemaExecute(Sender: TObject);
var
Stream: TBlobStream;
iFileHandle: Integer;
iFileLength: Integer;
iBytesRead: Integer;
Buffer: ^Byte;
begin
with OpenPictureDialog1 do
if Execute then
begin
ImageShema.Picture.LoadFromFile(FileName); // Only tiff files (ImageShema: TImage)

with DataModule1.tblTree do
begin
Edit;
Stream:=TBlobStream.Create(FieldByName('Picture') as TBlobField, bmWrite);

iFileHandle := FileOpen(FName, fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
Buffer := AllocMem(iFileLength);
iBytesRead := FileRead(iFileHandle, Buffer^, iFileLength);
FileClose(iFileHandle);

Stream.Write(Buffer^,iBytesRead);
end;
finally
FreeMem(Buffer,iFileLength);
Stream.Free;
end;
end;

Another one code, which raises the same error is:

procedure TMain.aLoadShemaExecute(Sender: TObject);
var
Stream: TBlobStream;
begin
with OpenPictureDialog1 do
if Execute then
begin
ImageScrollBox1.FileName:=FileName; // (ImageScrellBox1: TImageScrollBox)

with DataModule1.tblTree do
begin
Edit;
Stream:=TBlobStream.Create(FieldByName('Picture') as TBlobField, bmWrite);
ImageScrollBox1.SaveToStream(Stream,'TIF'); // Here raise the error
Post;
Stream.Free;
end;
end;
end;

My opinion is, that the method TTiffGraphic.SaveToStream doesn’t work correctly.
How you will comment all that?

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.