Solved

Converting StdPicture.Width to pixels?

Posted on 2003-10-30
2
1,302 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
[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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

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…
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…
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…

756 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