EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
321 stars 93 forks source link

Add StretchDrawTo method to TSVGIconImage #160

Closed PeterPanino closed 3 years ago

PeterPanino commented 3 years ago

The TSVGIconImage.PaintTo method draws a fixed-size image to the target Canvas.

Please add a similar method TSVGIconImage.StretchDrawTo(Canvas: TCanvas) that fills the whole target Canvas (independently from its size) with the SVG image. That would be more flexible.

carloBarazzetta commented 3 years ago

Actually if you set Stretch to True and Proportional to False the component draws the image as the size of the SVGIconImage target. Look into Paint method: LSVG.PaintTo(Canvas.Handle, TRectF.Create(LOrigin, LWidth, LHeight), FProportional); It's quite simple to add the method you need: try yourself and make a pull-request ;-)

carloBarazzetta commented 3 years ago

Look into CategoryButtonTest, there is an example to draw "stretched" image from an SVGIconImage to a PaintBox, calling:

  SVGIconImage.svg.PaintTo(PaintBox1.Canvas.Handle,
    PaintBox1.ClientRect, False);

The last param (False) is for KeepAspectRatio: with False the image is painted as the entire dimension of the paintbox. You must download the latest version of the repo.