Results 1 to 6 of 6

Thread: Dpi setting affects Print Size

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Dpi setting affects Print Size

    With ref to http://www.vbforums.com/showthread.php?t=625535
    That one is resolved so I'm starting another...

    LaVolpe,

    Ref. your Post #2 in the ref thread; The problem I have with that is if I do;

    Code:
    Private Sub Command1_Click()
    
        Dim thePic As StdPicture
        
        Set thePic = LoadPicture("C:\MyDir\UserLogo.bmp")
        imagewidth = ScaleX(thePic.Width, vbHimetric, vbCentimeters)
        imageheight = ScaleY(thePic.Height, vbHimetric, vbCentimeters)
    
        Printer.ScaleMode = vbCentimeters
        Printer.Print " ";
        Printer.PaintPicture thePic, 1, 1, imagewidth/2, imageheight/2
        Printer.EndDoc
    
    End Sub
    I get a bigger image printed when the display is using 120dpi than when it is using 96dpi, I'd like it to be printed the same size regardless of the screen dpi setting. I'm guessing this is because the StdPicture reflects the Display DC rather than the Printer DC. Any way around that?

    Merri, I have tried Printer.ScaleX and Y but no difference. It appears to be thePic.Width and thePic.Height which are changing not the ScaleX/Y conversion factors.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Dpi setting affects Print Size

    So are you saying that if you load a 256x256 image, the imageWidth & imageHeight variables are not 256x256? I'd try it myself, but am not near a point I can do pc restarts due to dpi setting changes.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Dpi setting affects Print Size

    Yes.

    Test code;

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    
        Dim thePic As StdPicture
        Dim imagewidth&, imageheight&
        
        Printer.ScaleMode = vbCentimeters
        
        Set thePic = LoadPicture("C:\Gds\UserLogo.bmp")
        
        MsgBox thePic.Width & " " & thePic.Height   'returned values affected by Windows dpi setting
        
    '    imagewidth = Printer.ScaleX(thePic.Width, vbHimetric, vbCentimeters)
    '    imageheight = Printer.ScaleY(thePic.Height, vbHimetric, vbCentimeters)
    '
    '    Printer.Print " ";
    '    Printer.PaintPicture thePic, 1, 1, imagewidth / 2, imageheight / 2
    '    Printer.Print
    '
    '    Printer.EndDoc
    
    End Sub

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Dpi setting affects Print Size

    I have a feeling that those values should change... why aren't you using ScaleX/ScaleY as you were shown?

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Dpi setting affects Print Size

    Quote Originally Posted by Magic Ink View Post
    Yes.

    Test code;

    MsgBox thePic.Width & " " & thePic.Height 'returned values affected by Windows dpi setting
    I'd expect that. But does the following return different values? when using Printer.ScaleX/Y
    MsgBox imageWidth & " " & imageHeight
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Dpi setting affects Print Size

    If I unrem the remmed code (which includes Printer.ScaleX/Y) the printed image size changes!

Posting Permissions

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



Click Here to Expand Forum to Full Width