Image stretching
Author Message
Image stretching

I have an image control with its stretch propery set to true.  On top of the
image, I have placed an icon.  Now, if I resize the image, I want the icon
to move to the new location.  Is there an easy way of calculating the new
co-ordinates of the icon?

Ian

Sat, 20 Aug 2005 02:45:38 GMT
Image stretching
Hi Ian:

Quote:
> I have an image control with its stretch propery set to true.  On top of the
> image, I have placed an icon.  Now, if I resize the image, I want the icon
> to move to the new location.  Is there an easy way of calculating the new
> co-ordinates of the icon?

I think it would be a whole lot easier to create a new image when the app
first loads that contains a combination of the original image with the icon
printed on top of it.  You could do this using a picture box with autoredraw = true
and the paintpicture method.

Doug.

Sat, 20 Aug 2005 04:33:18 GMT
Image stretching

Quote:
> I have an image control with its stretch propery set to true.
On top of the
> image, I have placed an icon.  Now, if I resize the image, I
want the icon
> to move to the new location.  Is there an easy way of
calculating the new
> co-ordinates of the icon?

To translate the center of the icon's position, you can do
something like this:

'this is the position of imgStretch -- before resizing
Dim fBeforeLeft as Single
Dim fBeforeTop as Single
Dim fBeforeWidth as Single
Dim fBeforeHeight as Single

'position of icon's center point
Dim fCenterX as Single
Dim fCenterY as Single

'determine center point before, in "before stretch" units
fCenterX = (imgIcon.Left - fBeforeLeft) / fBeforeWidth
fCenterY = (imgIcon.Top - fBeforeTop) / fBeforeHeight

'translate center point into "after stretch" units
fCenterX = fCenterX * imgStretch.Width + imgStretch.Left
fCenterY = fCenterY * imgStretch.Height + imgStretch.Top

'position the icon image
imgIcon.Move fCenterX - imgIcon.Width / 2, _
fCenterY - imgIcon.Height / 2
imgIcon.ZOrder vbBringToFront

Sat, 20 Aug 2005 05:25:37 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages