Results 1 to 8 of 8

Thread: easy way to convert Image.Size (twips) to height and width?

  1. #1
    Join Date
    Oct 2004
    Posts
    9

    easy way to convert Image.Size (twips) to height and width?

    Before I start to do my own bitwise operations to convert Image.Size (represented in twips) to get the height and width (inches), I would like to ask the forum if there is an already dot net written function to do this for me?

    any help would be apperciated.

  2. #2
    Join Date
    Nov 2004
    Age
    44
    Posts
    6
    In .Net, Image.Size is in pixels, not twips.

    And there really isn't any way to convert pixels to inches. It depends entirely on the size and resolution of the device (display or printer.)

    For instance, a 96x96 image on a 19" monitor at a resolution of 1280x1024 is going to be roughly 1/2". On a 21" monitor at 1280x1024, it would be closer to 3/4". On a 21" monitor at 800x600, it would be over 1".

    Likewise, a 300x300 image dumped to a printer with a 600x600 resolution will result in a 1/2" x 1/2" image. On a lower quality printer with a 300x300 resolution, you would get a 1" x 1" image.
    Last edited by THerring; November 10, 2004 at 16:12:43.

  3. #3
    Join Date
    Oct 2004
    Posts
    9
    you are right. The documentation that I have says twips.

    thanks for the help.

  4. #4
    Join Date
    Oct 2004
    Posts
    9
    does dot net already find pixels per inch for us?

    If not, looks like I'll have to revert to look the user's resolution with the reflection class.

    thanks for the info herring
    Last edited by dwin; November 10, 2004 at 16:38:36.

  5. #5
    Join Date
    Nov 2004
    Age
    44
    Posts
    6
    Originally posted by dwin
    does dot net already find pixels per inch for us?
    I've never run across any such thing. Some device contexts may be able to provide resolution information, but I'm not certain about that.

    The problem is that an inch is a real-world measurement. There's really no effective way for the application/framework/OS to know whether the image is being displayed on a 15" monitor or an overhead projector. This makes it realistically impossible to do inches on a display device.

    Printers, on the other hand, report their resolutions as dots per inch (dpi) through the device context. It should be possible to do such conversions for print media. For instance, when you place an image in a Word document, you resize it based on the size it needs to be on the printed page. However, we are now entering the realm of "Things I've never needed to do"(tm), so I can't provide much concrete assistance with that.

  6. #6
    Join Date
    Oct 2004
    Posts
    9
    Actuallly,

    the page on txtcontrols is 8"x11" right?

    so I just need to scale the image percentage towards the page to ensure that the user gets the desired width and height in inches.

  7. #7
    Join Date
    Oct 2004
    Posts
    9
    thank you very much Therring, your input has be very helpful to me

  8. #8
    Join Date
    Mar 2005
    Location
    Spain - Mallorca
    Age
    37
    Posts
    15

    convert twips to pixel

    if you want the image size in pixels you just have to use the functions

    Microsoft.VisualBasic.Compatibility.VB6.TwipsPerPi xelX and
    Microsoft.VisualBasic.Compatibility.VB6.TwipsPerPi xelY

    They return the number of logical twips per pixel for an object measured horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).

    So, to know every size in pixels of your images you just have to...

    Code:
    For Each l_Image As TXTextControl.Image In TextControl1.Images
        Dim l_WidthPix As Integer
        Dim l_HeightPix As Integer
    
        l_WidthPix = l_Image.Size.Width / Microsoft.VisualBasic.Compatibility.VB6.TwipsPerPixelX()
        l_HeightPix = l_Image.Size.Height / Microsoft.VisualBasic.Compatibility.VB6.TwipsPerPixelY()
    
    Next

Similar Threads

  1. V13 Html tags for height and width
    By Gunthard Pupke2 in forum TX Text Control ActiveX
    Replies: 1
    Last Post: October 19, 2006, 13:14:26
  2. HTML tags width and height not exported?
    By Gunthard Pupke in forum TX Text Control ActiveX
    Replies: 4
    Last Post: September 19, 2006, 15:16:28
  3. ObjectInsertAsChar exact width and height
    By Unregistered in forum TX Text Control ActiveX Server
    Replies: 1
    Last Post: August 4, 2004, 13:41:15
  4. Need to change the page height and width without loading a document.
    By im_umer_rasheed in forum TX Text Control ActiveX
    Replies: 0
    Last Post: December 25, 2003, 07:54:40
  5. zoom (width / height)
    By Rodrigo in forum TX Text Control ActiveX
    Replies: 0
    Last Post: February 5, 2003, 17:51:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •