Recent

Author Topic: TBGRABitmap Resize Image help  (Read 2537 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
TBGRABitmap Resize Image help
« on: February 24, 2018, 10:07:40 pm »
Hi All

Thanks in advance!

I am coding an image placement editor and want the option to click on a sprite {TBGRABitmap) and resize with the mouse ( as is used in most image editors where there is a focus rectangle with mouse adjustable corners - Can draw and detect this no issues :) ).

I have used the resample option but this creates a VERY blurred image which is not acceptable. I then saw the TBGRABitmap.Canvas.Stretchdraw which may be useful but I cannot work out
a) could I use this?
b) how to use this
   b1) Do I create a new 'resized' TBGRABitmap and stretchdraw onto it <HOW?>

I want the expanded image to be as clear as possible.

Any other ideas VERY welcome!

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: TBGRABitmap Resize Image help
« Reply #1 on: February 24, 2018, 11:49:56 pm »
If the source image is of bad quality when you resize it to a bigger one of course it will be blured, doesn't matter if you use BGRABitmap or Photoshop.

When downsizing, you must choose the right filter when using the Resize method, to keep a good quality.

I can suggest you to keep the original image in memory and then use resample in a new copy using a good filter

See list of filters here:
http://wiki.lazarus.freepascal.org/BGRABitmap_Miscellaneous_types#Images_and_resampling

And using BGRABitmap.Canvas is discouraged (by the author of bgrabitmap), since it is slow.

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: TBGRABitmap Resize Image help
« Reply #2 on: February 25, 2018, 09:58:02 am »
If you're stretching images on the fly and want to use no filtering, you can use StretchPutImage function.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018