Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Image (or thumbnail) scaling / sizing / stretching

Posted on 2003-10-29
6
Medium Priority
?
458 Views
Last Modified: 2013-11-22
Hello,

Can I do the following in VB6...

  At design-time, specify an area of a form, which is 500 x 500 pixels, which will be used to display an image
  At run-time, specify the image to be displayed in the area of the form (for example "d:\picture.JPG")
  If the selected images width <= 500 and height <= 500, then automatically display image at it's actual size
  If the selected images width > 500 or height > 500, then automatically resize image to fit 500 x 500, while retaining proportions

Which components should I be looking at?  (For example PictureBox or Image?)
Which properties / methods should I be looking at to determine the image's actual size?
Which properties / methods should I be looking at to resize image to fit 500 x 500?

*** Thank you for your time ***

Regards,
James
0
Comment
Question by:James20000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Expert Comment

by:marcomania
ID: 9645151
I don't have a exact solution for you, but try the following

take both a image-box and a picture box (what of both has an auto resize option)

load the picture in the box - without out-resize
take the picture width and height
if its larger than you want, load it to the box with auto-resize and then back to the original box which is visible for the user.






0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9645757
From where do you load the image?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9645794
Sorry:
Did you try with me.paintpicture method?
I haven't VB installed to test it but i think (in a rush)
me.scalemode=vbpixels
me.paintpicture loadpicture(""d:\picture.JPG"),0 ,0,500,500

should do it...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Djinn_ro
ID: 9646240
read the file format for bmp, jpg, gif, tiff, etc.
In the HEADER of these file is located dimension of picture (width and height)
try www.wotsit.org
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 400 total points
ID: 9650229
Try with this:

Private Sub Form_Click()
Dim pic As StdPicture, H As Integer, W As Integer, frmW As Integer, frmH As Integer
' replace with correct path and filename
Set pic = LoadPicture("n:\credicop.jpg")
With pic
    H = Int(Me.ScaleX(pic.Height, vbHimetric, vbPixels))
    W = Int(Me.ScaleY(pic.Width, vbHimetric, vbPixels))
    frmW = Me.ScaleWidth
    frmH = Me.ScaleHeight
End With
If frmW > W Or frmH > H Then
    Me.PaintPicture pic, 0, 0, W, H, , , , , vbSrcCopy
Else
    Me.PaintPicture pic, 0, 0, frmW, frmH, , , , , vbSrcCopy
End If
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9652565
That' was just an example, i think you need to use a select case statement to manage the various scenarios.
Cheers
Thanks for "A" grade.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question