[ 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:
procedure TEnvision.SaveImage(FileName: TFileName);
{ Description:
- Save the image opened in the envision object.
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.
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 :=
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 }

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

// Save the file ...

{ 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;
// Set the properties of the TiffImage to save the first page ...

// Save the first page of the image ...

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

// Append the page ...
end; { for - TiffImage.FrameCount }
// Restore the current page ...
FCurrentPage := LoadedPage;

// Cleanup allocated memory ...
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;
on E:Exception
do raise EEnvision.Create(Format(ErrSaveFile, [E.Message]));
end; { except - Save the file }
end; { procedure TEnvision.SaveImage }

NOTE #1: TEnvision is declared as following:
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 ...


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