[英]Java ESC/POS Image full width Printing
我正在嘗試使用本博客中給出的 Esc/Pos 命令打印圖像。 它打印正常,但我想將圖像與中心對齊並適合紙張尺寸。 我打印這張圖片:
並輸出如下:
我的代碼與這篇博文相同,但我將getPixelsSlow(BufferedImage image)
方法更改為這兩種方法,因為 Android 沒有BufferedImage
類。
private int[][] getPixelsSlow(Bitmap image) {
int width = image.getWidth();
int height = image.getHeight();
int[][] result = new int[height][width];
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
result[row][col] = getRGB(image, col, row);
}
}
return result;
}
private int getRGB(Bitmap bmpOriginal, int col, int row) {
// get one pixel color
int pixel = bmpOriginal.getPixel(col, row);
// retrieve color of all channels
int R = Color.red(pixel);
int G = Color.green(pixel);
int B = Color.blue(pixel);
return Color.rgb(R, G, B);
}
如何以全寬打印圖像? 謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.