Connecting Tech Pros Worldwide Forums | Help | Site Map

Fit large picture in PictureBox

Dick
Guest
 
Posts: n/a
#1: Nov 21 '05
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



Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Fit large picture in PictureBox


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
[color=blue]
>
> In my application I have a picturebox that must contain previews of[/color]
picture[color=blue]
> 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
>
>[/color]


Dick
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Fit large picture in PictureBox


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" <notfirstname@planet.nl> wrote in message
news:On7j7kllEHA.1244@TK2MSFTNGP15.phx.gbl...[color=blue]
> Dick,
>
> The picturebox has in my opinion although it derives from control the most
> special properties, one of them is
>
> sizemode
>[/color]
http://msdn.microsoft.com/library/de...emodetopic.asp[color=blue]
>
> I hope this helps?
>
> Cor
>[color=green]
> >
> > In my application I have a picturebox that must contain previews of[/color]
> picture[color=green]
> > 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
> >
> >[/color]
>
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Fit large picture in PictureBox


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
[color=blue]
> Thanks for the answer, but that doesn't do the trick with pictures that[/color]
are[color=blue]
> larger than the control itself.
> The only that works is sizemode 'StretchImage', but then the image is
> deformed.
>
> "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> news:On7j7kllEHA.1244@TK2MSFTNGP15.phx.gbl...[color=green]
> > Dick,
> >
> > The picturebox has in my opinion although it derives from control the[/color][/color]
most[color=blue][color=green]
> > special properties, one of them is
> >
> > sizemode
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...emodetopic.asp[color=blue][color=green]
> >
> > I hope this helps?
> >
> > Cor
> >[color=darkred]
> > >
> > > In my application I have a picturebox that must contain previews of[/color]
> > picture[color=darkred]
> > > files. The picturebox must always have the same size. For small[/color][/color][/color]
images[color=blue][color=green][color=darkred]
> > > 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
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Dick
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Fit large picture in PictureBox


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" <notfirstname@planet.nl> wrote in message
news:OCPTTyllEHA.3756@TK2MSFTNGP11.phx.gbl...[color=blue]
> Dick,
>
> It does a scrollbar will come up in your form when that is, depending on[/color]
the[color=blue]
> setting of course assuming you did not only look to StrechImage.
>
> Cor
>[color=green]
> > Thanks for the answer, but that doesn't do the trick with pictures that[/color]
> are[color=green]
> > larger than the control itself.
> > The only that works is sizemode 'StretchImage', but then the image is
> > deformed.
> >
> > "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> > news:On7j7kllEHA.1244@TK2MSFTNGP15.phx.gbl...[color=darkred]
> > > Dick,
> > >
> > > The picturebox has in my opinion although it derives from control the[/color][/color]
> most[color=green][color=darkred]
> > > special properties, one of them is
> > >
> > > sizemode
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...emodetopic.asp[color=blue][color=green][color=darkred]
> > >
> > > 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[/color][/color]
> images[color=green][color=darkred]
> > > > 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
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Jorge
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Fit large picture in PictureBox


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[color=blue]
>-----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[/color]
the image inside[color=blue]
>resized with no deformation if that's possible.
>
>"Cor Ligthert" <notfirstname@planet.nl> wrote in message
>news:OCPTTyllEHA.3756@TK2MSFTNGP11.phx.gbl...[color=green]
>> Dick,
>>
>> It does a scrollbar will come up in your form when[/color][/color]
that is, depending on[color=blue]
>the[color=green]
>> setting of course assuming you did not only look to[/color][/color]
StrechImage.[color=blue][color=green]
>>
>> Cor
>>[color=darkred]
>> > Thanks for the answer, but that doesn't do the trick[/color][/color][/color]
with pictures that[color=blue][color=green]
>> are[color=darkred]
>> > larger than the control itself.
>> > The only that works is sizemode 'StretchImage', but[/color][/color][/color]
then the image is[color=blue][color=green][color=darkred]
>> > deformed.
>> >
>> > "Cor Ligthert" <notfirstname@planet.nl> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
>> > news:On7j7kllEHA.1244@TK2MSFTNGP15.phx.gbl...
>> > > Dick,
>> > >
>> > > The picturebox has in my opinion although it[/color][/color][/color]
derives from control the[color=blue][color=green]
>> most[color=darkred]
>> > > special properties, one of them is
>> > >
>> > > sizemode
>> > >
>> >[/color]
>>[/color]
>http://msdn.microsoft.com/library/default.asp?[/color]
url=/library/en-
us/cpref/html/frlrfsystemwindowsformspictureboxclasssizemo
detopic.asp[color=blue][color=green][color=darkred]
>> > >
>> > > I hope this helps?
>> > >
>> > > Cor
>> > >
>> > > >
>> > > > In my application I have a picturebox that must[/color][/color][/color]
contain previews of[color=blue][color=green][color=darkred]
>> > > picture
>> > > > files. The picturebox must always have the same[/color][/color][/color]
size. For small[color=blue][color=green]
>> images[color=darkred]
>> > > > that fit, everything is ok.
>> > > >
>> > > > How can I fit in larger pictures?
>> > > > (Ideally would be that the picture is centered[/color][/color][/color]
and fit in the box)[color=blue][color=green][color=darkred]
>> > > >
>> > > > Is this possible with the standard control?
>> > > > (if not, are there other controls who can do it[/color][/color][/color]
out there?)[color=blue][color=green][color=darkred]
>> > > >
>> > > > Tia
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >[/color]
>>
>>[/color]
>
>
>.
>[/color]
Dick
Guest
 
Posts: n/a
#7: Nov 21 '05

re: Fit large picture in PictureBox


I will try it.
Thanks.

"Jorge" <anonymous@discussions.microsoft.com> wrote in message
news:8dd901c4966e$5de8e6d0$a301280a@phx.gbl...[color=blue]
> 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[color=green]
> >-----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[/color]
> the image inside[color=green]
> >resized with no deformation if that's possible.
> >
> >"Cor Ligthert" <notfirstname@planet.nl> wrote in message
> >news:OCPTTyllEHA.3756@TK2MSFTNGP11.phx.gbl...[color=darkred]
> >> Dick,
> >>
> >> It does a scrollbar will come up in your form when[/color][/color]
> that is, depending on[color=green]
> >the[color=darkred]
> >> setting of course assuming you did not only look to[/color][/color]
> StrechImage.[color=green][color=darkred]
> >>
> >> Cor
> >>
> >> > Thanks for the answer, but that doesn't do the trick[/color][/color]
> with pictures that[color=green][color=darkred]
> >> are
> >> > larger than the control itself.
> >> > The only that works is sizemode 'StretchImage', but[/color][/color]
> then the image is[color=green][color=darkred]
> >> > deformed.
> >> >
> >> > "Cor Ligthert" <notfirstname@planet.nl> wrote in[/color][/color]
> message[color=green][color=darkred]
> >> > news:On7j7kllEHA.1244@TK2MSFTNGP15.phx.gbl...
> >> > > Dick,
> >> > >
> >> > > The picturebox has in my opinion although it[/color][/color]
> derives from control the[color=green][color=darkred]
> >> most
> >> > > special properties, one of them is
> >> > >
> >> > > sizemode
> >> > >
> >> >
> >>[/color]
> >http://msdn.microsoft.com/library/default.asp?[/color]
> url=/library/en-
> us/cpref/html/frlrfsystemwindowsformspictureboxclasssizemo
> detopic.asp[color=green][color=darkred]
> >> > >
> >> > > I hope this helps?
> >> > >
> >> > > Cor
> >> > >
> >> > > >
> >> > > > In my application I have a picturebox that must[/color][/color]
> contain previews of[color=green][color=darkred]
> >> > > picture
> >> > > > files. The picturebox must always have the same[/color][/color]
> size. For small[color=green][color=darkred]
> >> images
> >> > > > that fit, everything is ok.
> >> > > >
> >> > > > How can I fit in larger pictures?
> >> > > > (Ideally would be that the picture is centered[/color][/color]
> and fit in the box)[color=green][color=darkred]
> >> > > >
> >> > > > Is this possible with the standard control?
> >> > > > (if not, are there other controls who can do it[/color][/color]
> out there?)[color=green][color=darkred]
> >> > > >
> >> > > > Tia
> >> > > >
> >> > > >
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>[/color]
> >
> >
> >.
> >[/color][/color]


Closed Thread