Results 1 to 2 of 2

Thread: [RESOLVED] Print Bitmap

  1. #1

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Resolved [RESOLVED] Print Bitmap

    How do i go about reading a bitmap from a file and sending it via a StreamWriter to a printer?

    so far i 've been using this code:

    VB Code:
    1. Dim i As Integer
    2.         Dim bBitmap As New Bitmap(p_bmLoc)
    3.         Dim bByte((bBitmap.Width * bBitmap.Height * 3) - 1) As Byte
    4.         For y As Integer = 0 To bBitmap.Height - 1
    5.             For x As Integer = 0 To bBitmap.Width - 1
    6.                 Dim oColour As Color = bBitmap.GetPixel(x, y)            
    7.                 bByte(i) = oColour.R
    8.                 bByte(i + 1) = oColour.G
    9.                 bByte(i + 2) = oColour.B
    10.                 i += 3
    11.             Next
    12.         Next
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  2. #2
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Print Bitmap

    Hi Strider!

    A way you could do this, is by usage of a Printing.PrintDocument class and by GDI+

    Printing.PrintDocument have event call PrintPage that have a Graphics handle parameter, that you can use to insert any GDI Object such as a Bitmap



    VB Code:
    1. Private WithEvents mRpt As Printing.PrintDocument
    2.  
    3. Private Sub mRpt _PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mRpt.PrintPage
    4.  
    5.     Dim Bmp As New Bitmap("MyImageFile")
    6.     Dim ImgLocation As New Point(10, 10)
    7.     e.Graphics.DrawImage(Bmp, ImgLocation)
    8.  
    9. End Sub

    Hope it help !!
    Using VS 2010 on Fw4.0

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