Solved

Image (or thumbnail) scaling / sizing / stretching

Posted on 2003-10-29
6
409 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now