Solved

Image (or thumbnail) scaling / sizing / stretching

Posted on 2003-10-29
6
419 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

778 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