Solved

Printing BMP Graphics From File

Posted on 2003-11-10
7
829 Views
Last Modified: 2013-11-19
How do you print a BMP file on the printer?  I would like to print it in the high resolution the image is saved in (300 dpi).  I used the PictureBox before as the intermediate step but it does not preserve the 300 dpi resolution when it was printed out on the printer.  I don't mind using an API call if somebody can show me how.
0
Comment
Question by:limva
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9717598
The only way that comes to mind is to use paintpicture (or is that what you've already tried)

Syntax

object.PaintPicture picture, x1, y1, width1, height1, x2, y2, width2, height2, opcode

0
 
LVL 3

Expert Comment

by:gajendra
ID: 9719958
I would like to extend TomLaw1999's comment.

Use LoadPicture to load the bitmap graphic from the file first and then Print it with PaintPicture.

Dim pic as StdPicture

set pic = LoadPicture("FileName.Bmp")

Printer.PaintPicture pic, .....

Hope that helps

Gajendra
0
 

Author Comment

by:limva
ID: 9720182

Hi TomLaw1999 and gajendra.

Thanks for your comments.  I've tried PaintPicture using the PictureBox with disappointing result.  However, I will try your suggestions (using the "set pic = ...") after I've installed the scanner tomorrow and let you guys know what happens.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:limva
ID: 9723741
OK, I scanned a document in 300 dpi resolution and saved it as a BMP file.  Then I used the following code in VB6 to print:

   Dim Pic As StdPicture
   Set Pic = LoadPicture("C:\Windows\Desktop\test.bmp")
   Printer.PrintQuality = 300
   Printer.PaintPicture Pic, 0, 0
   Printer.EndDoc

It printed out an oversized document.  That means VB converted the image into 72 dpi and printing it as such.  That is the exact problem I had using the PictureBox route.

Any other suggestions?
0
 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 100 total points
ID: 9724726
Hi Limva,

Have you tried something like:

 Printer.PaintPicture Pic, 0, 0,100,100

(The last two figures control the height & width
0
 

Author Comment

by:limva
ID: 9727360
Hi TomLaw1999,

I used the MS Word object to print:

    Dim Doc As Word.Document
    Set Doc = New Word.Document
    Doc.InlineShapes.AddPicture "C:\Windows\Desktop\test.bmp"
    Doc.PrintOut
    Doc.Close
    Set Doc = Nothing

The above code works.  Then I tested your code and the results of the 2 codes were identical.  Your code is simpler because it doesn't have to deal with the Word object.  I'll use your code and I'll give you the points!  Thanks!
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9729692
Thanks limva - must confess I never thought of using MS Word - good idea.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 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

16 Experts available now in Live!

Get 1:1 Help Now