Recent

Author Topic: Downscaling with Lanczos  (Read 4696 times)

dsiders

  • Hero Member
  • *****
  • Posts: 1326
Re: Downscaling with Lanczos
« Reply #15 on: May 27, 2024, 07:53:15 pm »
has anyone questioned the popup doc for the canvas.Draw(.....) ?

It states it calls the StretchDraw and so on, read the rest.

What is it specifically that *you* question? Give a fellow a goal...
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6791
Re: Downscaling with Lanczos
« Reply #16 on: May 27, 2024, 08:18:50 pm »
it's a misleading description of what happens in the end.

you call DRAW, which does not resize the image but the docs leads you to believe the image is going to be resized because it's calling the StretchDraw.

 In reality, the image does not get resized at all, it just gets clipped off.


in any case, if you are on windows and want to natively use StretchDraw for a faster experience for a real stretch of an image.
Code: Pascal  [Select][+][-]
  1.   SetStretchBltMode(hDC,HALFTONE);
  2.                 StretchBlt(hDC,630,500,200,200, hDC, 0,0,400,400, SRCCOPY);
  3.  


The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1326
Re: Downscaling with Lanczos
« Reply #17 on: May 27, 2024, 08:28:33 pm »
it's a misleading description of what happens in the end.

you call DRAW, which does not resize the image but the docs leads you to believe the image is going to be resized because it's calling the StretchDraw.

 In reality, the image does not get resized at all, it just gets clipped off.

Thank you. That I can address.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

lainz

  • Hero Member
  • *****
  • Posts: 4661
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Downscaling with Lanczos
« Reply #18 on: May 27, 2024, 11:11:37 pm »
Try with BGRABitmap:
https://forum.lazarus.freepascal.org/index.php/topic,41745.msg290230.html#msg290230
Code: Pascal  [Select][+][-]
  1. var
  2.   bgra: TBGRABitmap;
  3. begin
  4.   bgra := TBGRABitmap.Create('file.jpg');
  5.   BGRAReplace(bgra, bgra.Resample...)
  6.  
  7. end;

dsiders

  • Hero Member
  • *****
  • Posts: 1326
Re: Downscaling with Lanczos
« Reply #19 on: May 28, 2024, 03:30:33 am »
it's a misleading description of what happens in the end.

you call DRAW, which does not resize the image but the docs leads you to believe the image is going to be resized because it's calling the StretchDraw.

 In reality, the image does not get resized at all, it just gets clipped off.
[/code]

I am planning to patch the topic to the following:

Code: Text  [Select][+][-]
  1. Draws the image content in SrcGraphic on the canvas at the specified position.
  2.  
  3. Draw is reintroduced method in TCanvas; it reimplements the
  4. inherited method to use the TGraphic instance in SrcGraphic as the
  5. container with the image content drawn in the method.
  6.  
  7. No actions are performed in the method if SrcGraphic has not been assigned.
  8.  
  9. Draw calls the StretchDraw method to render the content in SrcGraphic on the
  10. canvas at the position specified in X and Y. The Width and Height in SrcGraphic
  11. set the bounds for the image rectangle applied to the canvas using StretchDraw.
  12. Since a stretch mode is not enabled when StretchDraw is called, the source
  13. graphic is not enlarged or shrunk to the canvas size. The source graphic is
  14. clipped if its bounds exceeds the canvas bounds. The Draw method in SrcGraphic
  15. performs the actions needed to position and rendering the content to the Pixels
  16. in the canvas.
  17.  
  18. CopyMode determines the raster operation performed for the Pixels affected on
  19. the canvas.
  20.  
  21. Calling Draw causes the OnChanging and OnChange events to be signalled (when
  22. assigned). OnChanging occurs prior to calling Draw in the TGraphic instance.
  23. OnChange occurs after calling Draw in the TGraphic instance.
  24.  

Is that more accurate?
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6791
Re: Downscaling with Lanczos
« Reply #20 on: May 28, 2024, 12:53:33 pm »
Yes, that looks much better.
Thank you
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1326
Re: Downscaling with Lanczos
« Reply #21 on: May 28, 2024, 06:44:02 pm »
Yes, that looks much better.
Thank you

Thanks for the heads-up.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018