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: [1]2345678910 ]


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

Date Posted: 03:08:53 05/28/04 Fri
Author: Norrit
Subject: Save mp tiff with annotations

Hi ...

I can't get the following to work:
Saving multipage tiff images with annotations ...

Code I have is:
<code>
procedure TEnvision.SaveImage(FileName: TFileName);
{ Description:
- Save the image opened in the envision object.
}
var
TiffImage : TTiffGraphic;
Editor : TAnnotationsEditor;

procedure SetTiffGraphicAndAnnotationsEditor(Index: Word);
{ Description:
- If the currentpage is the index then load the TTiffGraphic and
TAnnotationsEditor with the displayed image, otherwise load with the
values stored in the original file.
}
begin
if CurrentPage = Index
then begin
// Set the frame to the index ...
if FrameCount > 0 then TiffImage.CurrentFrame := Index;

// Set the annotationtag to save the annotations ...
if Assigned(TEnvision(Self).FDisplayEditor)
then TiffImage.AnnotationTag :=
TEnvision(Self).FDisplayEditor.SaveToString
else TiffImage.AnnotationTag := '';
end { if - CurrentPage = 1 }
else begin
// Load the first page (including annotations) ...
// Call the protected procedure (overload) ...
GotoPage(Index, TiffImage, Editor);

// Set the annotationtag to save the annotations ...
if Assigned(Editor)
then TiffImage.AnnotationTag := Editor.SaveToString
else TiffImage.AnnotationTag := '';
end; { else - CurrentPage = 1 }
end; { procedure SetTiffGraphicAndAnnotationsEditor }

var
i : Word;
LoadedPage : Word;
begin
// Only if an image is loaded ...
if Graphic.IsEmpty
then raise EEnvision.Create(ErrNoFileLoaded);

// Save the file ...
try

{ NOTE: Now only tiff is supported as multipage image file. Other multipage
file types should be created in their own graphic class ...
}

// Save the multipage formats ...
if (Graphic is TTiffGraphic)
then begin
TiffImage := TTiffGraphic(Graphic);

// Create a temporary annotations editor ...
Editor := TAnnotationsEditor.Create(nil);

// Store the currentpage ...
LoadedPage := CurrentPage;
FCurrentPage := 0;
try
// Set the properties of the TiffImage to save the first page ...
SetTiffGraphicAndAnnotationsEditor(1);

// Save the first page of the image ...
TiffImage.SaveToFile(FileName);

// Save all other pages ...
for i := 2 to TiffImage.FrameCount
do begin
// Set the properties of the TiffImage to append the page ...
SetTiffGraphicAndAnnotationsEditor(i);

// Append the page ...
TiffImage.AppendToFile(FileName);
end; { for - TiffImage.FrameCount }
finally
// Restore the current page ...
FCurrentPage := LoadedPage;

// Cleanup allocated memory ...
FreeAndNil(Editor);
end; { finally - Temporary annotations editor }
end { if - Graphic is TTiffGraphic }
else Self.SaveToFile(FileName);

// Image is saved, so modified is False ...
if (FileName <> TempFile) then FModified := False;
except
on E:Exception
do raise EEnvision.Create(Format(ErrSaveFile, [E.Message]));
end; { except - Save the file }
end; { procedure TEnvision.SaveImage }
</code>

NOTE #1: TEnvision is declared as following:
type
TEnvision = class(TImageScrollBox)

NOTE #2: CurrentPage is a property which returns the current page ...

The code above does save a multipage image, but forgets the annotations ... If I message the TiffImage.AnnotationTag it is filled with the correct information, but it isn't saved in the new image ...

Please help :D ...

MvG
Peter

[ 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.