Solved

Converting StdPicture.Width to pixels?

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

746 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

10 Experts available now in Live!

Get 1:1 Help Now