Solved

Converting StdPicture.Width to pixels?

Posted on 2003-10-30
2
1,290 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

839 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