I'm working on a small C++Builder FireMonkey project that uses both TImage and TImageControl components.
I'm trying to display the RGB pixel colors of the underlying bitmaps when the mouse moves over both of these controls. The online help has a couple of functions called ConvertLocalPointTo and ConvertLocalPointFrom. C++Builder help doesn't have any information on these routines.
I also noticed that TImageControl has a MarginWrapMode property which allows you to center and fill the bitmap to the control, whereas TImage doesn't.
What are they defining as a local point? Is that the point in the control, or the point in the bitmap? When you look in the help file, the typical Embarcadero help message is shown:
Embarcadero Technologies does not currently have any additional information.
Does anyone have a programming example of how to convert between the 2 coordinate systems?
When a Bitmap fills the client area of a
TImage/Control, converting aTImage-local coordinate into aTBitmap-local coordinate is fairly simple. Calculate a ratio of theTImageX coordinate to theTImagewidth, and then apply that same ratio to theTBitmapwidth to get theTBitmapX coordinate, eg:BitmapX := (ImageX / ImageWidth) * BitmapWidthThen, do the same for the Y coordinates relative to the heights.
Obviously, if the
TBitmapdoes not fully fill theTImage, then you will have to subtract any margins, offsets, etc from theImageX/ImageYandImageWidth/ImageHeightas needed.