Board index » cppbuilder » New to Graphics Programming ...

New to Graphics Programming ...


2003-11-27 01:48:56 PM
cppbuilder43
Good Day All,
I am new to the Graphics Programming arena. I am looking to do some simple
things, I think.
I would like to place an image on a form, be able to zoom in or out. Also, lets
say the image is a map, I want to super impose symbols that the user chooses on
to the map, but, they must be in relation to a point on the base image on the
form. For example, if the user decides that they want to move an item west 6Km,
given that I know how many pixels make up 6km, technically, I should be able to
set the Left attribute of the superimposed image - right ?
Any help, links or suggested reading would be greatly appreciated.
Thanks, Nick
 
 

Re:New to Graphics Programming ...

Nick,
Quote
I would like to place an image on a form, be able to zoom in or out.
The easiest way to do this is to place a TImage inside a TScrollBox. For an
example, copy and paste the following DFM text onto your form at
design-time...
object ScrollBox1: TScrollBox
Left = 36
Top = 68
Width = 621
Height = 489
TabOrder = 1
object Image1: TImage
Left = 0
Top = 0
Width = 1024
Height = 1024
Stretch = True
end
end
Using this setup, to zoom, you'd set the Image's Stretch property to true,
and then adjust the Image's Width and Height properties relative to the
width and height of the original image that it contains; e.g., to zoom in by
a factor of 2 on an image that's originally 150x200, you'd set the Image's
Width and Height to 300 and 400, respectively.
Quote
Also, lets say the image is a map, I want to super impose symbols
that the user chooses on to the map, but, they must be in relation
to a point on the base image on the form.
You can place additional TImage or TShape objects inside the TScrollBox for
the symbols. Then, because the background image has the same Parent control
as the symbols (i.e., they're all children of the ScrollBox), you'd position
these objects relative to ClientOrigin of the ScrollBox (or relative to the
Left and Top properties of the background image).
The only problem I find with a stretched TImage inside a TScrollBox is that
the TImage does more (re)drawing than is necessary, which can lead to
performance issues. If you experience this, see tinyurl.com/qlpx.
Best of luck,
Damon (TeamB)
 

Re:New to Graphics Programming ...

WOW - you guys are amazing. That is such a simple solution - it completely
eluded me. You guys really know the tool well. Thanks for the help. I am going
to get on it right away.
Nick
Borland Forever ...
 

{smallsort}