Android Example Downloading and Printing 1 Bit BMP to ESC/POS Printer

Discussion in 'Tutorials & Examples' started by infow, Dec 1, 2016.

  1. infow

    infow Member Licensed User

    Using the feature of resident images of Datecs dpp250. This is the way I found with Erel help to convert a 1 Bit BMP to ESC format, download to the printer, clean printer memory, write printer memory and print.
    It´s quite slow to convert, but you can save a file with the ESC format, and dont need convert anymore.
    If you have a better or faster way to do this, please change the code and share.

    Code:
    Dim imagem As Bitmap, x As Int, y As Int
        imagem = 
    LoadBitmap(File.DirAssets, "testebmp3.bmp")

        
    Dim out As OutputStream
        out.InitializeToBytesArray(
    0)
        out.WriteBytes(
    Array As Byte(0x1D),0,1)         'GS
        out.WriteBytes(Array As Byte(0x2A),0,1)            '*
        out.WriteBytes(Array As Byte(imagem.Width/8),0,1)
        out.WriteBytes(
    Array As Byte(imagem.Height),0,1)

        
    Dim  bits As String
        
    Dim p() As Int
        p = getPixels(imagem, 
    0, imagem.Width, 00, imagem.Width, imagem.Height)
        
    For x = 0 To p.Length-1
            
    If p(x) = -1 Then bits = bits & "0" Else bits = bits & "1"
            
    If bits.Length = 8 Then
                out.WriteBytes(
    Array As Byte(RetBytePOS(bits)),0,1)
                bits = 
    ""
            
    End If
        
    Next
        Astream.Write(
    Array As Byte(0x1D0x2A00))       
        Astream.Write(out.ToBytesArray)
        Astream.Write(
    Array As Byte(0x1DAsc("/"), 0))
    End Sub
     

    Attached Files:

    f0raster0 and Erel like this.
  2. rboeck

    rboeck Well-Known Member Licensed User

    If you have to print a logo everytime the same, i made it in such way with windows: Prepare your printer driver to use a file, print your logo and you have the file, which you can later send to the printer. Maybe it can be that you have to remove some commands at the end of the print job like cutting or transport commands.
     
  3. infow

    infow Member Licensed User

    This print doesn´t have driver, it´s bluetooth direct. It use resident imagens, you send 1 time to the printer and prints anytime you want.
     
  4. cloner7801

    cloner7801 Active Member Licensed User

    what about this for b4i ?
    I cant find getPixels for b4i
    can anyone help me?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You should start a new thread in B4i forum with a link to this one.
     
    cloner7801 likes this.
  6. MAGAREY

    MAGAREY Member Licensed User

    When I try to print an image I get the following error:
    Code:
    Illegal division by zero at /Zebra/APL/APL-E.NRD line 5135, <SYSIN> line 16.
    Any idea what it could be?

    my printer is a Zebra iMZ320
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice