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: 12[3]45678910 ]


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

Date Posted: 10:31:27 05/22/03 Thu
Author: Kevin Strattan
Subject: Re: Erase page from Multipage TIFF take 2
In reply to: Michel 's message, "Re: Erase page from Multipage TIFF take 2" on 20:19:59 05/19/03 Mon

Michel,

The link to the previous post I was discussing is:

<a rel=nofollow target=_blank href="http://www.voy.com/5188/1/2305.html">http://www.voy.com/5188/1/2305.html</a>

I was able to get it to work, however I am concerned now. The only way I could get it to work is by NOT freeing the graphics at the end. This worries me as it may cause a memory leak? I'm now having problems with saving the rotation of ONE page in the middle of a multi-page tiff ... any suggestions? I'm researching a file stream approach as I think the approach I used for the Delete page is not going to work.

This is the code I used for the Deleting page, if you have any suggestions in regards to memory leaks or such, please let me know :
{******************************************************************************}
procedure TformTiffViewer.DeletePage1Click(Sender: TObject);
{******************************************************************************}
var
grNewTiff, grOldTiff : TTiffGraphic;
iFrame : Integer;
strImgFileName : string;
begin
if mrOK = MessageDlg('Confirm deletion of page ' + IntToStr(mstrFrame)
+ ' from this image?', mtConfirmation, mbOkCancel, 0) then
begin
{ The user has chosen to delete the frame. In order for this to work }
{ the old graphic must be loaded minus the missing frame and saved as }
{ a new tiff file. }
{ Create the local directory for processing documents in one shot. }
if not DirectoryExists('c:\CACM') then
if not ForceDirectories('c:\CACM') then
raise Exception.Create('Cannot create c:\CACM');
{ Initialize strImgFileName }
strImgFileName := 'C:\CACM\cacmedit.tif';

grNewTiff := ImgScrllBx1.Graphic as TTiffGraphic;
grOldTiff := ImgScrllBx1.Graphic as TTiffGraphic;

for iFrame := 1 to ImgScrllBx1.ImageCountFromFile(mstrImgFileName) do
begin
grOldTiff.ImageToLoad := iFrame;
grOldTiff.LoadFromFile(mstrImgFileName);
{ skip the images you want to delete }
if iFrame = mstrFrame then
continue
else
if iFrame = 1 then
grNewTiff.SaveToFile(strImgFileName)
else
grNewTiff.AppendToFile(strImgFileName);
end;

DeleteFile(mstrImgFileName);
RenameFile(strImgFileName, mstrImgFileName);

updownPage.Min := 1;
mstrImgCnt := mstrImgCnt - 1;
updownPage.Max := mstrImgCnt;
lblMaxPages.Caption := InttoStr(mstrImgCnt) + ' page(s)';
EditPage.Text := '1';

{ Reload the image starting from the first page }
ImgScrllBx1.LoadFromFile(mstrImgFileName, 1);
end;
end;

>
>Hi Kevin,
>
>I apologize for the delayed answer, I was away for the
>past week.
>
>I was not able to locate the original thread. You can
>post the link directly to the thread.
>
>To erase a single page from a tiff file, you need to
>reconstruct a new file, without the page to delete.
>
>When using TTiffGraphic.AppendToStream, make sure the
>Compression property is properly set before the call.
>The Width and Height should be properly set after
>reading an image though.
>
>tcGroup4 compression uses the "2d" CCITT encoding.
>
>Best regards,
>
>Michel
>
>
>>I am using the demo version of Envision to see if it
>>can accomodate my application before we purchase a
>>license. As I am attempting to do this, I'm trying to
>>replicate the functionality of deleting single pages
>>(aka frames) from a Tiff.
>>
>>I found your posting from 1/5/2003 and tried using
>>that code however it doesn't seem to be working. It
>>looks like the new graphic is being created with a
>>bunch of "Unknown" details (by this I mean, Height,
>>Width, Image Type and Compression). A typical Tiff
>>Image that we manipulate is using Compression CCITT
>>Group4 2D. I noticed in the supporting documentation
>>that Group4 is covered, but no mention of 2D is made.
>>Is my problem related to lack of support for CCIT
>>Group4 2D? Or is something else awry?
>>
>>Your attention in this matter would be greatly
>>appreciated.
>>
>>Respectfully,
>>
>>Kevin Strattan

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


Replies:

  • Re: Erase page from Multipage TIFF take 2 -- Kevin Strattan, 16:40:38 05/22/03 Thu
    [ 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.