473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Convert Twips to pixel

Hi all
I have some points in twips measurement.how can I convert them to pixel
measurement ?

thanks
May 29 '06 #1
4 15970
perspolis wrote:
Hi all
I have some points in twips measurement.how can I convert them to
pixel measurement ?


wasn't twips something from the VB5/6 world?

If you retrieve the coordinates in .net code, you can always get them
in pixel format.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
May 29 '06 #2
I have some pints in twips and .Net convert them to pixel.

"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> wrote in message
news:xn***************@news.microsoft.com...
perspolis wrote:
Hi all
I have some points in twips measurement.how can I convert them to
pixel measurement ?


wasn't twips something from the VB5/6 world?

If you retrieve the coordinates in .net code, you can always get them
in pixel format.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

May 29 '06 #3
perspolis wrote:
I have some points in twips measurement.how can
I convert them to pixel measurement ?


A twip is 1/1440 of an inch, so it depends on the resolution of the
screen being used and will vary between computers. You need to know
the screen size in pixels (easy to discover) and in inches (harder or
impossible at run-time) to do this conversion. It will probably be
easier for you to redesign the system from scratch to use pixels.

Eq.
May 29 '06 #4

Paul E Collins wrote:
perspolis wrote:
I have some points in twips measurement.how can
I convert them to pixel measurement ?


A twip is 1/1440 of an inch, so it depends on the resolution of the
screen being used and will vary between computers. You need to know
the screen size in pixels (easy to discover) and in inches (harder or
impossible at run-time) to do this conversion. It will probably be
easier for you to redesign the system from scratch to use pixels.


This is the correct advice - convert to using pixels, which is the .NET
way of doing things.

However, for those that are interested, it is possible to use Reflector
to examine the Microsoft.VisualBasic.Compatibility dll, in which is
contained translations of the VB6 methods Screen.TwipsPerPixelX and
Screen.TwipsPerPixelY (you can guess what they do). This is the direct
output from Reflector; interested parties will not find it hard to
pursue undefined references. As Paul E Collins suggests, it is indeed
'hard' to do at runtime:

private static void SetUpTwipsPerPixel(bool Force /* = false */)
{
if (!Support.m_IsTwipsPerPixelSetUp || Force)
{
Support.m_TwipsPerPixelX = 0;
Support.m_TwipsPerPixelY = 0;
try
{
IntPtr ptr1 =
NativeMethods.GetDC(NativeMethods.NullIntPtr);
if (!ptr1.Equals(NativeMethods.NullIntPtr))
{
Support.m_TwipsPerPixelX = 1440 / ((double)
NativeMethods.GetDeviceCaps(ptr1, 0x58));
Support.m_TwipsPerPixelY = 1440 / ((double)
NativeMethods.GetDeviceCaps(ptr1, 90));

NativeMethods.ReleaseDC(NativeMethods.NullIntPtr, ptr1);
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
ProjectData.ClearProjectError();
}
Support.m_IsTwipsPerPixelSetUp = true;
if ((Support.m_TwipsPerPixelX == 0) ||
(Support.m_TwipsPerPixelY == 0))
{
Support.m_TwipsPerPixelX = 15;
Support.m_TwipsPerPixelY = 15;
VB6Errors.RaiseError(7,
Resources.GetResourceString("Misc_SetUpTwipsPerPix el"));
}
}
}
--
Larry Lard
Replies to group please

May 30 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cefrancke | last post by:
I've been working with the Twips/Pixel issue and after reviewing the Acc.Dev.Hnd book and the groups, the standard seems to be ... 640x480 15 Twips/Pixel 800x600 12 Twips/Pixel 1024x768 12...
1
by: Sachin | last post by:
Hi If we check Font.Height property it returns the value in pixel. How to convert the same in Twips? please guide -- sachin
0
by: Sachin | last post by:
How to convert GraphicsUnit .Word to Twips? -- sachin
0
by: Robert W. | last post by:
I'm building a simple Windows Form with tabs at the top. I'm writing some code to ensure that each tab will be wide enough to accomodate the text that will go in it - for both English and other...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
1
by: Jeremy | last post by:
The real reason I ask is, I want to compare the size of a winform label with the size of a crystal field. Crystal uses twips. What units are used in winforms? Pixels? Points? Jeremy
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
8
by: platinumhimani | last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale -i have tried to convert a 24-bit image to grayscale using setpixel and getpixel functions, in vb.net but i am unable to save...
2
by: minouparhizkar | last post by:
hi could anyone helping me to finish this i have no idea how to implement the program in java im trying to grabbing the pixel from image and then convert it to the txt file .i did that but it didnt...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.