Solved

Converting StdPicture.Width to pixels?

Posted on 2003-10-30
2
1,261 Views
Last Modified: 2010-05-18
Hello,

How can I convert StdPicture.Width to pixels?  For example:

  Private Sub Form_Click()
     Dim pic As StdPicture
     Set pic = LoadPicture("test.jpg")
     MsgBox CStr(Screen.TwipsPerPixelX) + " x " + CStr(Screen.TwipsPerPixelX)    '15 x 15
     MsgBox CStr(pic.Width) + " x " + CStr(pic.Height)     '1323 x 1323
  End Sub

This code reports that TwipsPerPixelX is 15 and pic.Width is 1323.   The image is actually 50 pixels width.  Therefore in this case I can divide 1323 by 26.46 to establish pixels?

Will this formula work on ANY platform, or is there a better formula to convert StdPicture.Width to pixels?
Or is there a better way in VB to establish an image width in pixels?

Thanks,
James
0
Comment
Question by:James20000
2 Comments
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 50 total points
ID: 9658050
Try this,
    Dim Pic As StdPicture
    Dim PicWidth  As Long
    Dim PicHeight As Long
   
    Set Pic = LoadPicture("c:\windows\dell.bmp")
   
    PicWidth = ScaleX(Pic.Width, vbHimetric, vbPixels)
    PicHeight = ScaleY(Pic.Height, vbHimetric, vbPixels)

Thanks,
~ fantasy ~
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9658523
two birds with one shoot, isn't it?
:))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

911 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

20 Experts available now in Live!

Get 1:1 Help Now