473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How do i Set an autosize(or auto fit)an image into the picturebox

1
Hello,

I am putting together a simple picture viewing program to view jpg pictures. I have the picturebox autosize set to true. I dont have the
picturebox in a pannel set to autoscroll, so if I get a picture that is
larger than the width/height of the containing form (pannel, etc) I can't able to
scroll. When I open this pic in Microsoft Photo Editor - it
opens to 50% zoom by default. How can I set the zoom in my picturebox which
is set to autosize? How do I set the zoom? Like if I get the image size say
1900x800 I will automatically zoom the image to 50%. How do I set the zoom
of the image? I tried Img.Zoom, but there is no .Zoom.

Thanks,
Dravid.
Jun 27 '07 #1
2 7769
kadghar
1,295 Expert 1GB
i think you can use PictureSizeMode;
e.g.

Image1.PictureSizeMode = 1

If you set it to 0 I'll put the picture in its original size even if it doesnt fit in your Image (wont show the complete picture)

If you set it to 1 it'll strech to fit your image

if you set it to 2 i'll zoom <--- i think this is the one you need.

(I dont have VB here, only VBA so i dont remember if this applies to for a picture box, but you can always use an Image)

Good Luck
Kad
Jun 27 '07 #2
I noted it from a forum and found it working as my requirement
Expand|Select|Wrap|Line Numbers
  1. 'Picture1.Picture = Image1(1).Picture
  2.     Picture1.ScaleMode = 3
  3.     Picture1.AutoRedraw = True
  4.     Picture1.PaintPicture Picture1.Picture, _
  5.         0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
  6.         0, 0, _
  7.         Picture1.Picture.Width / 26.46, _
  8.         Picture1.Picture.Height / 26.46
  9.     Picture1.Picture = Picture1.Image
Oct 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Harvey | last post by:
Hello: I am trying to use Autosize=true on a long string and it extends off of my form, rather than increasing the number of lines of the Label as the documentation says it should do. Would...
2
by: Jake | last post by:
Hi, I have a page with a bunch of thumbnails that when clicked, open the full size image in a new window. They are all different sizes and its a bit unprofessional looking. I'd like to find a...
2
by: Tim Wallace | last post by:
I'm using Visual Studio 2003. Is there a way one can cause columns in a DataGrid to autosize? Also, is there a way to cause the last column to take up the remaining space between the end of the...
9
by: Kevin Westhead | last post by:
Can anyone confirm whether or not there are any limits imposed on the widths of autosized columns in a list-view. I've found that the autosizing appears to have an upper limit, i.e. it will not...
7
by: Georges Bessis | last post by:
The image I set as background are left at original size. In a picturebox, I can decide to strech the image. Can I do that to fill my background ? Regards GB
3
by: tedqn | last post by:
I'm using VS 2005. When user selects a image from the FileListBox, the code is PictureBox.ImageLocation = sFullPath PictureBox is set to AutoSize. When the newly loaded image is smaller...
1
by: Nathan Laff | last post by:
I have a panel that I want to AutoSize with an AutoSize mode of GrowAndShrink, but I only want it to autosize vertically. Reason being I have anchors set up to a usercontrol which can resize. ...
2
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So...
2
by: Joe Cool | last post by:
I am trying to display several images on a standard Windows Form. Each image is displayed in a PictureBox control that is 180,130 in size. I get the Primary Screen size to determine how many images...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.