Java png黑了

时间:2016-05-26 03:17:12

标签: java image png

我有一张图片,当我尝试将其从我的收据打印机打印出来时,我从数据库中取出它的图像。我认为它与压缩有关,但无法弄清楚如何在Java中添加初学者。谢谢

String imagex = "iVBORw0KGgoAAAANSUhEUgAAAiwAAAByCAYAAABwbIpHAAAPn0lEQVR4nO3df6hk5XnA8W+2SwgicpASpIg9bYMlJciYgIWwodM0UCo23EIQWaidJiGgFNm2tghNFxYJaSrFmLCVtIjdposJS7puU7FSjFprmyWJu1vRuIrZ3Wy2i1lTXdf1uu6P2z+eOcyZM2fm/przY+Z+P3C4986dOeeZuXPnvOd93vd5QZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSapXAuwGDgA3NxyLJElSqcPAUm7rNBuOJElqu001Hy8Fri3c9ns1xyBJkmZM3Q2WoyW3XVlzDJIkSRN1GE4HLQFbGo1IkiSp4JsMN1aONRuOJEmaBXWnhD5c+Pnhmo8vSZK0rNcZ7mFJmg1HkiTNgrp7WIrHS2s+viRJmkF1Nlg6wBWF296o8fiSJGlG1dlgubrw8z9SPs1ZkiSpEQnDY1cO4PgVSZK0QnX1sNxR+HkXpoMkSVKLpMBFBr0rzzcazdrcArwKnAW+1HAskiSpAjsYTgfd1Gw4K5IAjwKLjFbmdTq2JElz6BCDE/1zDceyEh1ijE1ZQyXbek0FJ0nSRlTHGJY09/0DNRxvrVLgHuB7RKNlEntYJEmaIynwMtErcYj2nugT4BTlvSnHgfOF21ywUZKkOXKSwUk+bTaUUjuBM5Q3VHYC24i4TxR+l9YfqiRJqko2O+gY7epd6TE8tia/laWD9hbuc18tUUqSpMrdyOAE/+2GY4FoMD1IjFEZN5h235jH3lVy3zY1wCRJ0iplDYNzDE7u2xqMJwU+S8xQKmuk/IAoZNedsI9eyeMkSdIM6zE4qZ8jelqaUqwBk9/+iMmNlLyEmOGUPfYE9rBIkjSzUuBp2lHV9h7KGyr/Dlyzhv0lwJ7c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kSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSbX5f78dHdKssbBYAAAAAElFTkSuQmCC";

  public Bitmap StringToBitMap(String encodedString){
    try {
        byte [] encodeByte=Base64.decode(encodedString, Base64.DEFAULT);
        Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
        return bitmap;
    } catch(Exception e) {
        e.getMessage();
        return null;
    }
}
    Bitmap bm = StringToBitMap(imagex);
    StarBitmap starbitmap = new StarBitmap(bm, true, 200);
    commands.add(starbitmap.getImageEscPosDataForPrinting(false,true));

1 个答案:

答案 0 :(得分:1)

在大多数情况下,由于PC的渲染问题,PNG是黑色(透明区域),而不是因为服务器端错误。有时候PNG以反转颜色渲染,因为PNG的颜色深度很低(PNG-8等)。 我在很多时候都经历过高质量的PNG在许多浏览器中也都显示出阴暗的颜色和边缘(PNG-24)。 PNG错误的解决方案:

  • 尝试使用不同图像格式(JPEG,GIF等)的不同图像
  • 最好使用图像编辑工具重新格式化图像(Photoshop是最好的),然后将图像导出为PNG,然后存储在数据库中。
  • 尝试在不同环境(浏览器或其他PC)中显示相同的输出