public interface IImageDisplay extends IIngenicoApi
Usage example to display an image from a bitmap:
IImageDisplay
imageDisplay = ImageDisplay.getInstance(context); //Open imageDisplay sessionImageDisplayResult
displayResult = imageDisplay.openSession(); //Get Bitmap with 320x240 resolution and size less than 64koBitmap
image = getBitmap(); //Post image bitmap to tetra screen displayResult = imageDisplay.postImage(image); //Close imageDisplay session displayResult = imageDisplay.closeSession();
Usage example to generate and display an image:
String
text = "Hello World Line 1\nHello World Line 2\nHello World Line 3"; int width = 320; int height = 240;IImageDisplay
imageDisplay = ImageDisplay.getInstance(context); // Open imageDisplay sessionImageDisplayResult
displayResult = imageDisplay.openSession(); // Clear tetra screen displayResult = imageDisplay.clear(); // New Bitmap with 320x240 resolution and size less than 64koBitmap
image =Bitmap
.createBitmap(width, height,Bitmap
.Config.ARGB_8888);Canvas
canvas = newCanvas
(image); // New antialised PaintPaint
paint = newPaint
(Paint
.ANTI_ALIAS_FLAG); // Text shadow GRAY Color paint.setShadowLayer(1f, 0f, 1f,Color
.DKGRAY); // Draw a multiple lines string int x = 0, y, sizeOff = 25, yOff = 50;String
[] lines = text.split("\n"); int[] colors = new int[lines.length]; int[] sizes = new int[lines.length];Typeface
[] typefaces = newTypeface
[lines.length]; int[][] colorsRGB = new int[lines.length][3]; for (int i = 0; i < lines.length; ++i) { for (int j = 0; j < 3; ++j) { colorsRGB[i][j] = (int)Math
.floor(Math
.random() * 256); } } for (int i = 0; i < lines.length; ++i) { colors[i] =Color
.rgb(colorsRGB[i][0], colorsRGB[i][1], colorsRGB[i][2]); sizes[i] = sizeOff; //NORMAL = 0; BOLD = 1; ITALIC = 2; typefaces[i] =Typeface
.defaultFromStyle(i); sizeOff += 5; }Rect
rect = newRect
(); y = yOff; for (int i = 0; i < lines.length; ++i) { // Text color paint.setColor(colors[i]); // Text size in pixels paint.setTextSize(sizes[i]); // Text style paint.setTypeface(typefaces[i]); canvas.drawText(lines[i], x, y, paint); paint.getTextBounds(lines[i], 0, lines[i].length(), rect); y = y + rect.height() + 15; // Space between lines is 15 } //Post image bitmap to tetra screen displayResult = imageDisplay.postImage(image); //Close imageDisplay session displayResult = imageDisplay.closeSession();
Modifier and Type | Method and Description |
---|---|
ImageDisplayResult |
clear()
Clear the screen by using a white image.
|
ImageDisplayResult |
closeSession()
Close image display session.
|
ImageDisplayResult |
openSession()
Open image display session.
|
ImageDisplayResult |
postImage(android.graphics.Bitmap image)
Send the bitmap to the customer screen.
|
connect, disconnect, isConnected
ImageDisplayResult openSession() throws IngenicoException
IngenicoException
- when session opening failsImageDisplayResult closeSession() throws IngenicoException
IngenicoException
- when the session closing failsImageDisplayResult clear() throws IngenicoException
IngenicoException
- when clearing the screen failsImageDisplayResult postImage(android.graphics.Bitmap image) throws IngenicoException
image
- bitmap object to sendIngenicoException
- when the image display fails