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:33:44 05/30/03 Fri
Author: Kai
Subject: ResizeTransform: Another Problem


Hi Michel ~

thanks for answering. Reworked my code a little (see entire relevant section below) and now I get an exception: Source graphic too small.

When I check DIBGraphic after loading, its size is 0 x 0?

After working with TPixelGraphic and Graphics32 I'd have expected it to have the dimensions of the loaded image...

Please help me again.

Thanks,
Kai


//-----------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
DIBGraphic := TDIBGraphic.Create;
end;

//-----------------------------------------------------
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DIBGraphic.Free;
end;

//-----------------------------------------------------
procedure Tform1.StretchDraw(SrcGraphic, DstGraphic: TDIBGraphic; const DstWidth, DstHeight: Integer);
var
StrDrawTransform: TResizeTransform;

begin
StrDrawTransform := nil;
try
StrDrawTransform := TResizeTransform.Create;
StrDrawTransform.Interpolated := True;
StrDrawTransform.Filter := ifTriangle;
StrDrawTransform.Height := DstHeight;
StrDrawTransform.Width := DstWidth;
//
if ( SrcGraphic.ImageFormat <> DstGraphic.ImageFormat ) then
begin
StrDrawTransform.OverrideDestFormat := True;
StrDrawTransform.DestFormat := DstGraphic.ImageFormat;
end;
StrDrawTransform.ApplyOnDest( SrcGraphic, DstGraphic);
finally
StrDrawTransform.Free;
end;
end;

//-----------------------------------------------------
procedure TForm1.button_LoadClick(Sender: TObject);
begin
(Sender as TButton).Enabled := False;
DIBGraphic.LoadFromFile('c:\girl.jpg');
// loads ok, I can do a SaveToFile here and check it with an imageeditor
end;

//-----------------------------------------------------
procedure TForm1.button_StretchDrawClick(Sender: TObject);
begin
(Sender as TButton).Enabled := False;
StretchDraw( DIBGraphic, imagescrollbox.Graphic, imagescrollbox.Width, imagescrollbox.Height);
imagescrollbox.Redraw(True);
end;

//-----------------------------------------------------

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


Replies:


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