1. Home
  2. Docs
  3. Axium
  4. API
  5. customerscreendisplay

customerscreendisplay

Usage example for a simple displaying for an loaded image:


IImageDisplay imageDisplay = ImageDisplay.getInstance(myContext);

Open imageDisplay session


DisplayResult displayResult = imageDisplay.openSession();

Get Bitmap with 320x240 resolution and size less than 64ko


Bitmap image = getBitmap();

Post image bitmap to tetra screen


displayResult = imageDisplay.postImage(image);

Close imageDisplay session


displayResult = imageDisplay.closeSession();

Usage example for a simple displaying for a newer 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 session


DisplayResult displayResult = imageDisplay.openSession();

// Clear tetra screen


displayResult = imageDisplay.clear();

// New Bitmap with 320x240 resolution and size less than 64ko


Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(image);
// New antialised Paint
Paint paint = new Paint(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 = new Typeface[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 = new Rect();
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();

How can we help?