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  
 
 [ 3 post ] 

 Relevant Pages 

1. Saving image stretch results?

2. what algorithm is behind Image Stretch?

3. Smooth Image Stretching & Shrinking

4. Smooth Image Stretching & Shrinking

5. picclip to image stretch

6. Apply a stretched image as a listview background

7. auto stretch a image in picturebox to a correct ratio

8. Stretched Image on PictureBox?

9. How to stretch image?

10. Strange Distortion of Image with Stretch = True

11. image/picture control - stretch info

12. stretching Images in VB5

 

 
Powered by phpBB® Forum Software