473,399 Members | 3,656 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,399 software developers and data experts.

Fit large picture in PictureBox

Hello,

In my application I have a picturebox that must contain previews of picture
files. The picturebox must always have the same size. For small images
that fit, everything is ok.

How can I fit in larger pictures?
(Ideally would be that the picture is centered and fit in the box)

Is this possible with the standard control?
(if not, are there other controls who can do it out there?)

Tia
Nov 21 '05 #1
6 1806
Dick,

The picturebox has in my opinion although it derives from control the most
special properties, one of them is

sizemode
http://msdn.microsoft.com/library/de...emodetopic.asp

I hope this helps?

Cor

In my application I have a picturebox that must contain previews of picture files. The picturebox must always have the same size. For small images
that fit, everything is ok.

How can I fit in larger pictures?
(Ideally would be that the picture is centered and fit in the box)

Is this possible with the standard control?
(if not, are there other controls who can do it out there?)

Tia

Nov 21 '05 #2
Thanks for the answer, but that doesn't do the trick with pictures that are
larger than the control itself.
The only that works is sizemode 'StretchImage', but then the image is
deformed.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
Dick,

The picturebox has in my opinion although it derives from control the most
special properties, one of them is

sizemode
http://msdn.microsoft.com/library/de...emodetopic.asp
I hope this helps?

Cor

In my application I have a picturebox that must contain previews of

picture
files. The picturebox must always have the same size. For small images
that fit, everything is ok.

How can I fit in larger pictures?
(Ideally would be that the picture is centered and fit in the box)

Is this possible with the standard control?
(if not, are there other controls who can do it out there?)

Tia


Nov 21 '05 #3
Dick,

It does a scrollbar will come up in your form when that is, depending on the
setting of course assuming you did not only look to StrechImage.

Cor
Thanks for the answer, but that doesn't do the trick with pictures that are larger than the control itself.
The only that works is sizemode 'StretchImage', but then the image is
deformed.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
Dick,

The picturebox has in my opinion although it derives from control the most special properties, one of them is

sizemode

http://msdn.microsoft.com/library/de...emodetopic.asp

I hope this helps?

Cor

In my application I have a picturebox that must contain previews of

picture
files. The picturebox must always have the same size. For small images that fit, everything is ok.

How can I fit in larger pictures?
(Ideally would be that the picture is centered and fit in the box)

Is this possible with the standard control?
(if not, are there other controls who can do it out there?)

Tia



Nov 21 '05 #4
A scrollbar will come up in you form:
So the control itself is resized I assume (made bigger).

I want the control to be the same size all the time and the image inside
resized with no deformation if that's possible.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OC**************@TK2MSFTNGP11.phx.gbl...
Dick,

It does a scrollbar will come up in your form when that is, depending on the setting of course assuming you did not only look to StrechImage.

Cor
Thanks for the answer, but that doesn't do the trick with pictures that

are
larger than the control itself.
The only that works is sizemode 'StretchImage', but then the image is
deformed.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
Dick,

The picturebox has in my opinion although it derives from control the most special properties, one of them is

sizemode

http://msdn.microsoft.com/library/de...emodetopic.asp

I hope this helps?

Cor

>
> In my application I have a picturebox that must contain previews of
picture
> files. The picturebox must always have the same size. For small images > that fit, everything is ok.
>
> How can I fit in larger pictures?
> (Ideally would be that the picture is centered and fit in the box)
>
> Is this possible with the standard control?
> (if not, are there other controls who can do it out there?)
>
> Tia
>
>



Nov 21 '05 #5
Hi Dick
I use the following to resize the image when its too big
to fit in the picturebox.

Dim caminho As String
Dim imagem As Image
Dim vista_reduzida As Image
Dim a As System.Drawing.Image.GetThumbnailImageAbort
Dim b As System.IntPtr

Try
imagem = imagem.FromFile(caminho)

Dim resolucao_V As Single = imagem.Width
Dim resolucao_H As Single = imagem.Height
If resolucao_H > 992 And resolucao_V > 712 Then
vista_reduzida = imagem.GetThumbnailImage(992, 712,
a, b)
Me.PictureBox1.Image = vista_reduzida
Else
Me.PictureBox1.Image = Image.FromFile(caminho)
End If

Catch ex As Exception
MessageBox.Show(ex.Message, "SIGDIN",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button3)
End Try

Kind Regards
Jorge
-----Original Message-----
A scrollbar will come up in you form:
So the control itself is resized I assume (made bigger).

I want the control to be the same size all the time and the image insideresized with no deformation if that's possible.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OC**************@TK2MSFTNGP11.phx.gbl...
Dick,

It does a scrollbar will come up in your form when that is, depending on
the
setting of course assuming you did not only look to

StrechImage.
Cor
> Thanks for the answer, but that doesn't do the trick with pictures that
are
> larger than the control itself.
> The only that works is sizemode 'StretchImage', but
then the image is > deformed.
>
> "Cor Ligthert" <no**********@planet.nl> wrote in message > news:On**************@TK2MSFTNGP15.phx.gbl...
> > Dick,
> >
> > The picturebox has in my opinion although it derives from control the most
> > special properties, one of them is
> >
> > sizemode
> >
>

http://msdn.microsoft.com/library/default.asp?

url=/library/en-
us/cpref/html/frlrfsystemwindowsformspictureboxclasssizemo
detopic.asp > >
> > I hope this helps?
> >
> > Cor
> >
> > >
> > > In my application I have a picturebox that must contain previews of > > picture
> > > files. The picturebox must always have the same size. For small
images
> > > that fit, everything is ok.
> > >
> > > How can I fit in larger pictures?
> > > (Ideally would be that the picture is centered

and fit in the box) > > >
> > > Is this possible with the standard control?
> > > (if not, are there other controls who can do it out there?) > > >
> > > Tia
> > >
> > >
> >
> >
>
>


.

Nov 21 '05 #6
I will try it.
Thanks.

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:8d****************************@phx.gbl...
Hi Dick
I use the following to resize the image when its too big
to fit in the picturebox.

Dim caminho As String
Dim imagem As Image
Dim vista_reduzida As Image
Dim a As System.Drawing.Image.GetThumbnailImageAbort
Dim b As System.IntPtr

Try
imagem = imagem.FromFile(caminho)

Dim resolucao_V As Single = imagem.Width
Dim resolucao_H As Single = imagem.Height
If resolucao_H > 992 And resolucao_V > 712 Then
vista_reduzida = imagem.GetThumbnailImage(992, 712,
a, b)
Me.PictureBox1.Image = vista_reduzida
Else
Me.PictureBox1.Image = Image.FromFile(caminho)
End If

Catch ex As Exception
MessageBox.Show(ex.Message, "SIGDIN",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button3)
End Try

Kind Regards
Jorge
-----Original Message-----
A scrollbar will come up in you form:
So the control itself is resized I assume (made bigger).

I want the control to be the same size all the time and

the image inside
resized with no deformation if that's possible.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OC**************@TK2MSFTNGP11.phx.gbl...
Dick,

It does a scrollbar will come up in your form when that is, depending on
the
setting of course assuming you did not only look to

StrechImage.
Cor

> Thanks for the answer, but that doesn't do the trick with pictures that are
> larger than the control itself.
> The only that works is sizemode 'StretchImage', but then the image is > deformed.
>
> "Cor Ligthert" <no**********@planet.nl> wrote in message > news:On**************@TK2MSFTNGP15.phx.gbl...
> > Dick,
> >
> > The picturebox has in my opinion although it derives from control the most
> > special properties, one of them is
> >
> > sizemode
> >
>

http://msdn.microsoft.com/library/default.asp?

url=/library/en-
us/cpref/html/frlrfsystemwindowsformspictureboxclasssizemo
detopic.asp
> >
> > I hope this helps?
> >
> > Cor
> >
> > >
> > > In my application I have a picturebox that must contain previews of > > picture
> > > files. The picturebox must always have the same size. For small images
> > > that fit, everything is ok.
> > >
> > > How can I fit in larger pictures?
> > > (Ideally would be that the picture is centered and fit in the box) > > >
> > > Is this possible with the standard control?
> > > (if not, are there other controls who can do it out there?) > > >
> > > Tia
> > >
> > >
> >
> >
>
>

.

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
10
by: Chris Coho, Jr. | last post by:
Ok, I'll explain the whole problem because there may be several ways to solve this and hopefully someone knows one. What I'm doing is creating a specialty template editor, similar to say a corel...
1
by: Dennis | last post by:
Hello, Ive to draw a line on a picture i used this code: Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) x1 = z.X y1 = z.Y lbl3 = "x1: " & x1 lbl4...
4
by: DraguVaso | last post by:
Hi, In my application I receive a Byte Stream (Dim bytFile() As Byte) which contains a jpeg-picture, which I want to display in a picturebox. I want to display it directly from the bytfile()...
2
by: Bill N. | last post by:
Using VB .Net 2003 Standard Edition. This simple form has a "File in Use" problem while the executable is running. Created this simple program to make sure that I hadn't done something in my...
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...
1
by: Jeff Williams | last post by:
I have several picture boxes on a form. I want to be able to drag pictures to this picture box. On the Drop how can I tell which picture box I am dropping the picture on. Te picture Box control...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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,...

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.