Recent

Author Topic: InflateOffsetRect or OffsetInflateRect, does it exist ? If not it should.  (Read 2692 times)

jamie

  • Hero Member
  • *****
  • Posts: 4848
I have a case where I deal with fixed sized images but show these images with a sizeable form via a Tpanel in the OnPaint event.
   
  All of this works fine and I also use HALF_TONE settings to get smooth glossy looking images when enlarge above their original size.

  But this is the point, I also have an optional grabber/Rubber band, what ever you want to call it to block mark a section on the form which also represents the image it's displaying but at different sizes most of the time, mainly smaller in my case.

  when ever I need to use this block reference which translate to a TRECT, I need to calculate the real reduced size and the offset so that I can get a correct TRECT value that matches the image location it is displaying..

 To do this, you need to calculate first the ratio of reduction then you need to call a OffsetRect and then a inflateRect with slightly split values.

 If such a function as I posted does not exist in the LCL libs, because $MS does not have it either, I purpose maybe one should be created and also added to the Trect helper ..

 This would be a great benefit of plotting Rects on the display surface and then translate that TRECT to the real image that its showing with little work. Because I do this a lot in code. Currently I write a function but it would be nice to have a Function like this to help out the more serious graphic coders.

 Any comments ?

The only true wisdom is knowing you know nothing

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9541
  • FPC developer.
TRect have helpers nowadays?

jamie

  • Hero Member
  • *****
  • Posts: 4848
yes I can put it into the helpers but the base function needs to be established first..

This operation is very common when viewing enlarged versions of an image that simply has been context painted to the screen using stretch operations during GUI updates. It saves lots of memory over creating an image of that size.

 Mapping programs use this same function.

  I will clean up what I have and ensure it looks suitable for most cases of the purpose and post it here..

 it should be a stand alone function and also added to the helper.

  I was considering using the Graphics32 unit that I down loaded here somewhere but I think that has some draw backs due to the implementation of it the last time I look. But then again it could of been that implementation.
The only true wisdom is knowing you know nothing

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9541
  • FPC developer.
Well, I use an opengl canvas for that. Everything is just TRectF multiplication with a zoom factor.

jamie

  • Hero Member
  • *****
  • Posts: 4848
That is basically what I am doing now but without OpenGL..  Although one day I may consider using GL for some in-depth graphics animation.

 I have a Record with the operators in it etc...
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018