Stretched Image on PictureBox? 
Author Message
 Stretched Image on PictureBox?

I have a map (.gif, .bmp or .jpg) which I would like to expand or
contract (not zoom, just resize) according to the form's size.  I
would also like to place a few lines and shapes on the map.  I have
tried 3 approaches as follows, and have run out of ideas

1) If I use an Image Control, the stretch property ensures that the
map stretches correctly, but I can't add any shapes or lines to the
image.

2) If I use a PictureBox control, I can add the shapes and lines, but
the map cannot be stretched.

3) If I use an Image control on a PictureBox, the image always comes
to the foreground and masks out the lines and shapes drawn on the
PictureBox.

Any thoughts welcome.

TIA
Mike



Wed, 18 Jun 1902 08:00:00 GMT  
 Stretched Image on PictureBox?

Quote:

> I have a map (.gif, .bmp or .jpg) which I would like to expand or
> contract (not zoom, just resize) according to the form's size.  I
> would also like to place a few lines and shapes on the map.  I have
> tried 3 approaches as follows, and have run out of ideas

> 1) If I use an Image Control, the stretch property ensures that the
> map stretches correctly, but I can't add any shapes or lines to the
> image.

> 2) If I use a PictureBox control, I can add the shapes and lines, but
> the map cannot be stretched.

> 3) If I use an Image control on a PictureBox, the image always comes
> to the foreground and masks out the lines and shapes drawn on the
> PictureBox.

> Any thoughts welcome.

> TIA
> Mike

You could make a copy of the picture in a standardPicture
  Dim pic as stdPicture

  Set pic = picbox.Picture
  hMemDC = CreateCompatibleDC(picbox.hDC)
  SelectObject hMemDC, pic.Handle

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal lDC As
Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal lDC As Long) As
Long   'Used when you finished using the stdPictur in the memory
Private Declare Function SelectObject Lib "gdi32" (ByVal lDC As Long,
ByVal hObject As Long) As Long

When resizing the pictureBox, use the new size to resize the
stdPicture(pic) with the API StretchBlt and copy to picBox

Private Declare Function StretchBlt Lib "gdi32.dll" (ByVal hDC As Long, _

  ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHEIGHT
As _
  Long, ByVal hSrcDC As Long, ByVal XSrc As Long, ByVal YSrc As Long,
ByVal _
  nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As
Long

Hope this helps, Bram.



Wed, 18 Jun 1902 08:00:00 GMT  
 Stretched Image on PictureBox?
Many thanks for the idea.  I tried it but the StretchBlt always seemed
to fail (error code 6).  However, changing from using a stdPicture to
a normal (though hidden on the form) PictureBox solved the problem.
This is my first introduction to StretchBlt.

Thanks again

Mike

On Wed, 26 Jul 2000 11:54:23 +0200, Bram van Empelen

Quote:

>You could make a copy of the picture in a standardPicture
>  Dim pic as stdPicture

>  Set pic = picbox.Picture
>  hMemDC = CreateCompatibleDC(picbox.hDC)
>  SelectObject hMemDC, pic.Handle

>Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal lDC As
>Long) As Long
>Private Declare Function DeleteDC Lib "gdi32" (ByVal lDC As Long) As
>Long   'Used when you finished using the stdPictur in the memory
>Private Declare Function SelectObject Lib "gdi32" (ByVal lDC As Long,
>ByVal hObject As Long) As Long

>When resizing the pictureBox, use the new size to resize the
>stdPicture(pic) with the API StretchBlt and copy to picBox

>Private Declare Function StretchBlt Lib "gdi32.dll" (ByVal hDC As Long, _

>  ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHEIGHT
>As _
>  Long, ByVal hSrcDC As Long, ByVal XSrc As Long, ByVal YSrc As Long,
>ByVal _
>  nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As
>Long

>Hope this helps, Bram.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

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

2. PictureBox replacement that stretches its contents URGENT

3. How to make a picturebox stretch its picture URGENT

4. Stretching the contents of a PictureBox

5. putting a imagebox picture on a picturebox in the stretch mode

6. Stretch picture in a picturebox

7. Using StretchBlt to Stretch a Bitmap/Icon in a PictureBox

8. Help!! Loading PictureBox FromStream and PictureBox.Image.Save

9. Question on PictureBox.Image = Image.FromFile(aFile)

10. Apply a stretched image as a listview background

11. Saving image stretch results?

12. load a Jpeg image into a picturebox or image control

 

 
Powered by phpBB® Forum Software