|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Draggin and dropping image from word/excel - Getting the image width and heightHi all
Im dragging and dropping an image from excel into a picturebox. Unfortunately the picturebox rescales the image to the size of the image box. Is there a way for me to retrieve the dragged image width and height before it is resized and therefore resize it back? Thanks "dug" <elad.se***@gmail.com> wrote in message You might consider using an Image control instead of a PictureBox. You cannews:1127342508.864784.100880@g14g2000cwa.googlegroups.com... > Hi all > > Im dragging and dropping an image from excel into a picturebox. > Unfortunately the picturebox rescales the image to the size of the > image box. Is there a way for me to retrieve the dragged image width > and height before it is resized and therefore resize it back? set the Image control's Stretch property to False and the control will resize to fit the graphic. -- Mike Microsoft MVP Visual Basic Thanks for that, that did the trick. However when I save the image it
is still enlarged (streched) is there a way to save it with its current dimensions? Thanks "dug" <elad.se***@gmail.com> wrote in message I've never been into this drag and drop stuff. I'm an old fashioned buggernews:1127421139.134714.96410@g44g2000cwa.googlegroups.com... > Thanks for that, that did the trick. However when I save the > image it is still enlarged (streched) is there a way to save it > with its current dimensions? myself, really. Are you saying that you are dragging an image (that apparently happens to be currently displayed at a specific small size in one application) into a Picture Box in your VB application? If so, where does the actual picture end up? For example, can you get at it as the Picture property of the Picture Box that you are dragging it into? You have to realise that all pictures (the original picture files, bmp, jpg or whatever) have a specific pixel size, which is often nothing at all like the "visible size" of the picture as it appears in a control or whatever. If you want to save a picture to disk at a smaller pixel size than its original pixel size then you need to resize it. One way to do so (if your machine is running at a decent and preferably full colour depth) is to draw it at the new desired size into a suitable device context (an autoredraw picture box, for example) using either the VB PaintPicture method or the API StretchBlt (using an appropriate stretchmode in the case of StretchBlt). Then you can save the resultant smaller pixel size image (the Image property of the picture box) as a bitmap using the VB SavePicture method (or, alternatively, you can save the small bitmap as a jpg using either an enormous amount of code which would be very difficult to write or, much easier, using the freely available Intel jpeg library). Can you tell us exactly what you are doing. Mike |
|||||||||||||||||||||||