VoyForums

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: 17:49:34 08/07/01 Tue
Author: Michel
Subject: Re: Assigning bmp to TDibGraphic
In reply to: darrell 's message, "Assigning bmp to TDibGraphic" on 15:58:10 08/07/01 Tue


Hi Darrell,

Your are getting a typecast error because Image1.LoadFromFile is loading a TBitmap, which is not derived from TDibGraphic.

This is because TBitmap is still registered with the VCL. To ensure you use Envision graphic classes you can do this:

var
DibGraphic : TDibGraphic;

begin
DibGraphic := EnDiGrph.NewDibGraphic(FileName);
Image1.Graphic := DibGraphic;
DibGraphic.Free;
if Image1.Graphic <> nil then
Image1.Graphic.LoadFromFile(FileName);
end;

This way you are sure that the Graphic property of Image1 is of a type derived from TDibGraphic.

Best regards,

Michel

>the code below works fine on PNG's, but when I try to
>convert a BMP, I get an "Invalid Typecast Error" when
>I try to assign the bmp it as a TDibGraphic. What am
>I doing wrong?
>
>TIA
>
>darrell
>
>
>
>
>*******************************************************
>*****
> image1 : Timage
> transform : TResizeTransform;
> graphic : TDibGraphic;
>
> image1 := Timage.create(nil);
> image1.LoadfromFile('c:\some.bmp')
> Graphic := image1.Picture.Graphic as TDibGraphic;
> Transform := TResizeTransform.Create;
>*******************************************************
>*****

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