Solved

Image (or thumbnail) scaling / sizing / stretching

Posted on 2003-10-29
6
431 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
Independent Software Vendors: 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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 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