That works! Thank you!!

I did try that method before though and then it misbehaved. I wonder what I
did differently...

Could I make a feature request? It would be nice and convenient to have a
getScaledPicture method in TPicture.

Charl

On 6/1/07, A.J. Venter <[EMAIL PROTECTED]> wrote:

Hi Michael,
Here is how I do it [I'm sure you can customise it to your needs,
factor can also be something like 0.5 (to scale to halfsize)] :)

A.J.

Procedure Scale(P1 : TPicture;Var P2:TPicture;Factor : Real);
Var
        ARect : TRect;
        X,Y : Integer;
Begin
X := Round(P1.Width * Factor);
Y := Round(P1.Height * Factor);
P2.Clear;
P2.BitMap.Width := X;
P2.BitMap.Height := Y;
Arect := Rect(0,0,X,Y);
P2.BitMap.Canvas.StretchDraw(ARect,P1.BitMap);
end;


On 6/1/07, Charl van Jaarsveldt <[EMAIL PROTECTED]> wrote:
> Hi Michael,
>
> I am still confused. :-( I cannot figure out how to get the FPImage
drawn. I
> thought perhaps the TImage.canvas.draw() function would do it - the code
> completion shows a draw(int, int, FPCustomImage) method, but when I
compile
> it the compiler says it it expects a TGraphic. Sure enough, the TCanvas
has
> one that expects TGraphic, and FPCanvas has one with FPCustomImage, but
it
> is not marked as overloaded, so I think the compiler assumes it is not
> available.
> I tried to find a way to get a TGraphic object from a FPCustomImage, but
no
> success.
>
> Thanks again for the help.
> Charl
>
>
> On 5/31/07, Charl van Jaarsveldt <[EMAIL PROTECTED]> wrote:
> > Ah, that would probably explain why I can't find it. :-)
> >
> > Yeah, I want to keep a cache of images in memory while keeping open
the
> possibility of actually saving the cache. Thanks for the help!
> > Charl
> >
> >
> >
> > On 5/31/07, Michael Van Canneyt <[EMAIL PROTECTED] > wrote:
> > >
> > >
> > > On Thu, 31 May 2007, Charl van Jaarsveldt wrote:
> > >
> > > > Thanks for the pointers. I can't find the extinterpolation unit
> though.
> > >
> > > in the FPC source tree:
> > >
> > > packages/fcl-image/src/extinterpolation.pp
> > >
> > > (it may not be present if you're working with the the 2.0.4 release)
> > >
> > > >
> > > > I think I am getting an idea of how to do what I want. The only
thing
> that
> > > > eludes me is how to get the FPImage into the TImage control? The
class
> > > > hierarchy seems rather confusing there. :-(
> > >
> > > If you just want to draw it, simply draw on the TImage canvas, that
> should work.
> > >
> > > But TImage itself has resizing capabilities, the imgview demo shows
how
> > > to do this. The disadvantage is that you can't save the resized
image,
> > > as far as I know.
> > >
> > > Michael.
> > >
> > > >
> > > > Thanks
> > > > Charl
> > > >
> > > > PS Please excuse my ignorance, this is the first time I am working
> with
> > > > images!
> > > >
> > > > On 5/31/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > >
> > > > >
> > > > > On Thu, 31 May 2007, Charl van Jaarsveldt wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > What is the best way to resize an image? I am thinking of
> something
> > > > > Java's
> > > > > > Image class has that will return a scaled image, and you can
> decide
> > > > > whether
> > > > > > it should be a good quality or a fast one. I don't necessarily
> want to
> > > > > write
> > > > > > it to a file, just in memory.  (I want to cache images in the
> memory and
> > > > > so
> > > > > > would like to have them much smaller than they are.)
> > > > >
> > > > > There are several resizing alogirthms present in FPC. see the
> > > > > extinterpolation unit.
> > > > > how it happens is: create a canvas, and draw the image on the
canvas
> with
> > > > > the correct
> > > > > interpolation.
> > > > >
> > > > > If you want to create a new image in memory, create an
> TFPImageCanvas with
> > > > > the desired
> > > > > size, and draw the original canvas with the correct
interpolation
> routine.
> > > > >
> > > > > Michael.
> > > > >
> > > > >
> _________________________________________________________________
> > > > >      To unsubscribe: mail [EMAIL PROTECTED] with
> > > > >                 "unsubscribe" as the Subject
> > > > >    archives at
> http://www.lazarus.freepascal.org/mailarchives
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > "I love deadlines. I especially love the whooshing sound they make
as
> they
> > > > fly by." - Douglas Adams
> > > >
> > >
> > >
> _________________________________________________________________
> > >      To unsubscribe: mail [EMAIL PROTECTED] with
> > >                 "unsubscribe" as the Subject
> > >    archives at
> http://www.lazarus.freepascal.org/mailarchives
> > >
> >
> >
> >
> > --
> > "I love deadlines. I especially love the whooshing sound they make as
they
> fly by." - Douglas Adams
>
>
>
> --
>
> "I love deadlines. I especially love the whooshing sound they make as
they
> fly by." - Douglas Adams


--
A.J. Venter
CEO - OutKast Solutions C.C.
http://www.outkastsolutions.co.za
Cell: +27 83 455 9978
Fax: +27 21 413 2800
Office: +27 21 591 6766

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives




--
"I love deadlines. I especially love the whooshing sound they make as they
fly by." - Douglas Adams

Reply via email to