[Lazarus] TImage - Getting image properties in 'canvas space'
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Apr 18 19:52:46 CEST 2012
On Tue, 17 Apr 2012 17:06:47 +0200
Marc Weustink <marc.weustink at cuperus.nl> wrote:
> Mattias Gaertner wrote:
> > On Tue, 17 Apr 2012 12:12:21 +0200
> > Marc Weustink<marc.weustink at cuperus.nl> wrote:
> >
> >> Mattias Gaertner wrote:
> >>>
> >>> Reimar Grabowski<reimgrab at web.de> hat am 16. April 2012 um 16:42
> >>> geschrieben:
> >>>
> >>> > Hi,
> >>> >
> >>> > I load a TLazIntfImage from disk, manipulate it and show it on my
> >>> form in a TImage. Center, Proportional and Stretch properties of the
> >>> TImage are set to true.
> >>> > Now I want to draw some overlays onto it (drawing to the canvas in
> >>> the OnPaint event). Therefor I obviously need the origin and dimensions
> >>> of the loaded image in 'canvas space', but I did not find a way to
> >>> retrieve this information. Do I have to calculate them myself or can the
> >>> TImage give me the needed information?
> >>>
> >>> The image is painted to the area defined by the protected method DestRect.
> >>>
> >>> Maybe this can be made public.
> >>>
> >>> At the moment you have to descend your own TImage class to access it or
> >>> write a hack class (e.g. via a class helper).
> >>
> >> TImage is not meant to draw to. If you want to custom paint your image,
> >> use a TPaintbox
> >>
> >> A TImage is for display only.
> >
> > TImage has a published OnPaint event. Painting some overlays makes
> > sense. And for this you need to know where the image is on the canvas.
>
> Who has added this ? Delphi has no OnPaint event.
>
> Yes, if we have an event, we should provide a way to paint.
> But to me this is a can of worms, since stretching is handled internally
> while the user event draws on the canvas, independent of the stretching.
> If you ask me, I wouldn't have added it.
I don't see many worms in the can, so I made it public.
It's a useful feature that costs us not much.
Mattias
More information about the Lazarus
mailing list