.NETGURU
Fit large picture in PictureBox
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.

Post a new message to this list...

Dick
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

Reply to this message...
 
    
Cor Ligthert
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/frlrfsystemwindowsformspictureboxclasssizemodetopic.asp

I hope this helps?

Cor

[Original message clipped]

Reply to this message...
 
    
Dick
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
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
[Original message clipped]

Reply to this message...
 
    
Dick
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jorge
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 clipped]

us/cpref/html/frlrfsystemwindowsformspictureboxclasssizemo
detopic.asp
[Original message clipped]

Reply to this message...
 
    
Dick
I will try it.
Thanks.

"Jorge" <Click here to reveal e-mail address> wrote in message
news:8dd901c4966e$5de8e6d0$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Drawing.Image
System.IntPtr
System.Web.UI.MobileControls.Image
System.Windows.Forms.MessageBox
System.Windows.Forms.MessageBoxButtons
System.Windows.Forms.MessageBoxDefaultButton
System.Windows.Forms.MessageBoxIcon




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification