1) How can we determine the bounding box for a text annotation given a loaded arbitrary image?
2) How can we get the Graphics class associated with a loaded arbitrary image?
Both of the questions above are aimed to achieve the same goal: How to scale your annotations such they they appear to be the same size(height/width) relative to any loaded image with a given resoltion/size.
When adding annotations to our images via an off-line process (process that requires no user intervention), we would like to determine the required size of the bounding box for a given string for a given image resolution such that we can render text proportionally to the size/resolution of the source image. The end result is we want the annotation to be the same size relative to the source image. Example: We want the word "Test" to be take up a quarter of the image's width where the height of the text can vary to accomidate for this.
To determine the text boudning box GDI/MFC we simply use CDC.GetTextExtent() passing in the string and we get the CSize class that bounds the text for the CDC. From here we can increase the Font size to get the desired text scaling and recheck the bounding box. There may be an easier way, if so, I'd be interested in hearing how that can be done.
Also, seems the SDK for Vintasoft has incorrectly named the "GetGraphics()" operation for the VintasoftImage class.
Code: Select all
Graphics g = image.GetGraphics();