Select your printer model

Parameters are refined by the selected printer.

addImage


Adds a raster image print command to the command buffer.

Prints Android.graphics.Bitmap class graphics.

A specified area of Android.graphics.Bitmap class graphics is binarized according to the mode, halftone, and brightness parameters and converted into a raster image.

The converted image is compressed or not compressed before transmission according to the compress parameter value.

One pixel of an image corresponds to one dot of the printer. When a transparent color is contained in the image, the background of the image is assumed to be white.

Syntax

 
public void addImage(Bitmap data, int x, int y, int width, int height, int color, int mode, int halftone, double brightness, int compress) throws Epos2Exception

Parameter

data

Specifies an instance of the android.graphics.Bitmap class.

x

Specifies the horizontal start position of the print area (in pixels).

Value

Description

Integer from 0 to 65534

Horizontal start position of the print area (in pixels)

y

Specifies the vertical start position of the print area (in pixels).

Value

Description

Integer from 0 to 65534

Vertical start position of the print area (in pixels)

width

Specifies the width of the print area (in pixels).

Value

Description

Integer from 1 to 65535

Width of the print area (in pixels).

height

Specifies the height of the print area (in pixels).

Value

Description

Integer from 1 to 65535

Height of the print area (in pixels).

color

Specifies the color.

Value

Description

Printer.COLOR_NONE

No printing

Printer.COLOR_1

First color

Printer.COLOR_2

Second color

Printer.COLOR_3

Third color

Printer.COLOR_4

Fourth color

Printer.PARAM_DEFAULT

Specifies the default value (first color).

mode

Specifies the color mode.

Value

Description

Printer.MODE_MONO

Monochrome (2 scales)

Printer.MODE_GRAY16

Multi-gradation (16 scales)

Printer. MODE_MONO_HIGH_DENSITY

Monochrome (2 scales), double density

Printer.PARAM_DEFAULT

Specifies the default (monochrome (2 scales)).

halftone

Specifies the halftone processing method.

Value

Description

Printer.HALFTONE_DITHER

Dithering (appropriate for printing graphics only)

Printer.HALFTONE_ERROR_DIFFUSION

Error diffusion (appropriate for printing text and graphics)

Printer.HALFTONE_THRESHOLD

Threshold (appropriate for printing text only)

Printer.PARAM_DEFAULT

Specifies the default (dithering).

Effective for the monochrome (2 scales) color mode only.

brightness

Specifies the brightness compensation value.

Value

Description

Real number from 0.1 to 10.0

Brightness compensation (gamma correction) value

Printer.PARAM_DEFAULT

Default (1.0)

When a value other than 1.0 is specified for the brightness compensation value, processing gets slower.

compress

Enables or disables compression.

Compressing print images can prevent white banding or streaks from occurring on printed images.

This works well when connecting with the printer using Bluetooth.

Value

Description

Printer.COMPRESS_DEFLATE

Compresses the image.

Printer.COMPRESS_NONE

Does not compress the image.

Printer.COMPRESS_AUTO

Automatically chooses to or not to compress the image internally.

Printer.PARAM_DEFAULT

Default
(automatically chooses to or not to compress the image internally)

Exception

When the process fails, Epos2Exception with one of the following error status occurs.

Error status

Description

ERR_PARAM

An invalid parameter was passed.

ERR_MEMORY

Memory necessary for processing could not be allocated.

ERR_FAILURE

An unknown error occurred.

Supplementary explanation

  • Use this API at the "beginning of a line." If this API is used elsewhere, it will be ignored.
  • If the area specified by x/y and width/height parameters does not fit within the image size specified by data parameter, ERR_PARAM will be returned as an exception.
  • The "compress" parameter is effective when the printer is connected via Bluetooth. For other printers, specify Printer.COMPRESS_AUTO.
  • Model

    Restriction

    TM-m10

    No restriction

    TM-m30/TM-m30II/TM-m30II-H/TM-m30II-NT/TM-m30II-S/
    TM-m30II-SL/TM-m30III/TM-m30III-H

    No restriction

    TM-m50/TM-m50II-H

    No restriction

    TM-P20/TM-P20II

    No restriction

    TM-P60II (Receipt)

    Firmware version 5.14 ESC/POS or later

    TM-P60II (Peeler)

    Firmware version 6.14 ESC/POS or later

    TM-P80

    Firmware version 1.02 ESC/POS or later

    TM-P80AC

    Firmware version 2.01 ESC/POS or later

    TM-P80II

    No restriction

    TM-T20II/TM-T20III

    No restriction

    TM-T70II

    No restriction

    TM-T82III

    No restriction

    TM-T88V/TM-T88VI

    No restriction

  • Printing may get slower if a transparent image is printed.
  • The multi-gradation and the compression of image data are not supported in the page mode. If you set those in the page mode, nothing will be printed.
  • Set an image size appropriate for the printer. If you set to print a large image, the API commands will be succeeded, but the printer may print nothing.
  • Even if the size of an image is printable, the ERR_MEMORY error may occur depending on the Android device specification. In such case, reduce the image size.
  • This API consumes a lot of the buffer provided in the printer. When using this API for LFCPrinter class, be sure to check the buffer size of the printer.
 

Quick Access

  • [Name]
  • [Format]
  • [Range]
  • [Description]
  • [Notes]

Epson ePOS SDK includes patented or patent pending functions. The contents must not be disclosed to third parties.


Epson ePOS SDK for Android

Jump to the top