Stretched Image on PictureBox?
Author |
Message |
Mike Fieldi #1 / 3
|
 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 |
|
 |
Bram van Empele #2 / 3
|
 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 |
|
 |
Mike Fieldi #3 / 3
|
 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 |
|
|
|