473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

autosizing picture in picturebox

DjPal
15 New Member
Hi,
I have a picturebox in C#, visual studio 2008. when a picture is sent into the picturebox, the image is does not resize to the size of the picturebox. I tried the "behaviour options" in visual studios properties but alas no luck.
Is there a way around this?

Thank you.
Mar 18 '10 #1
4 8371
tlhintoq
3,525 Recognized Expert Specialist
Take a look at the PictureBox in the MSDN
http://msdn.microsoft.com/en-us/libr...es(VS.71).aspx

It has a property called "SizeMode"
Mar 18 '10 #2
Sfreak
64 New Member
I think this can solve your problem (solved mine)

Expand|Select|Wrap|Line Numbers
  1. displayed_image.Image = original_image.GetThumbnailImage(172, 163, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
  2.         public bool ThumbnailCallback()
  3.         {
  4.             return true;
  5.         }
  6.  
Thumbnail the image and resize it.
Mar 18 '10 #3
tlhintoq
3,525 Recognized Expert Specialist
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.


Instead of hard coding sizes of 172 x 163 why not make it more dynamic and responsive. Not to mention a bit more re-usable.

If you are going to resize the image to fit the picturebox, then do that.
Expand|Select|Wrap|Line Numbers
  1. Image New image = original_image.GetThumbnailImage(myPictureBox.Width, myPictureBox.Height, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero)
  2.  
Now it works regardless of picturebox size. If you put this in the SizeChanged event handler it will even update as you resize the form.
Mar 18 '10 #4
Sfreak
64 New Member
Sure! thanks tlhintoq

Its also a nice solution

Sorry for the unformatted text... im new here

I Hope I could help
Mar 19 '10 #5

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

Similar topics

3
by: jeff | last post by:
Hiya, Im currently in the process of developing a picture browser, I want it to run off a CD, basically I have 2 questions for the group. The first is how do I get the program to only view the...
4
by: Chris | last post by:
Hi, I am trying to set the position of a picture inside a picturebox with the folowing code: pctOutput.Picture = LoadPicture(App.Path & "\picture.bmp", , , , ) I didn't know what to fill...
8
by: Pavan Arise | last post by:
Dear all.. I have a picturebox filled on a form. The picturebox has some graphics displayed on it.I was trying to save the picturebox, but continuesly failed to do so. I am clueless of why it is...
2
by: Michael Lehar | last post by:
Hallo I have a pictureBox with a picture loaded from file, then I draw some lines on the picture, and then I want to save the new picture. Befor I can draw lines I have to create a Graphics...
3
by: Rado | last post by:
Hello. In picturebox I have loaded some picture picturebox.image.fromfile(......) It's ok. But Have can I cancel Image from picturebox. Thanks.
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
2
by: Geoff Turner | last post by:
Hi all, I have an application that requires me to load an image into a picture or image or picclip control.Picture will be JPG format and of size 800 X 600 pixels. It will be displayed as say, 200...
5
by: GoGs | last post by:
How this vb6 code convert in c# dotnet2 ----- Image1.Visible = False Image1.Picture = LoadPicture("c:\image008.jpg") Dim x, y As Single x = Image1.Width y = Image1.Height Do While x...
0
debasisdas
by: debasisdas | last post by:
Add two picture boxes to a form. Set the ScaleMode property of both the pictureboxes to 3-Pixels. General declaration -------------------------------- Const ubx = 1000 Const uby = 500 Dim...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.