多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > andriod 藍牙打印問題

andriod 藍牙打印問題

來源:程序員人生   發布時間:2015-05-14 09:35:47 閱讀次數:2520次

用網上的1個gprinter.jar開發藍牙與收銀機的對接打印,出現以下毛病:x + width must be <= bitmap.width()

zs這1系列的毛病都源自于矩陣的檢測:

/** * Shared code to check for illegal arguments passed to getPixels() * or setPixels() * * @param x left edge of the area of pixels to access * @param y top edge of the area of pixels to access * @param width width of the area of pixels to access * @param height height of the area of pixels to access * @param offset offset into pixels[] array * @param stride number of elements in pixels[] between each logical row * @param pixels array to hold the area of pixels being accessed */ private void checkPixelsAccess(int x, int y, int width, int height, int offset, int stride, int pixels[]) { checkXYSign(x, y); if (width < 0) { throw new IllegalArgumentException("width must be >= 0"); } if (height < 0) { throw new IllegalArgumentException("height must be >= 0"); } if (x + width > getWidth()) { throw new IllegalArgumentException( "x + width must be <= bitmap.width()"); } if (y + height > getHeight()) { throw new IllegalArgumentException( "y + height must be <= bitmap.height()"); } if (Math.abs(stride) < width) { throw new IllegalArgumentException("abs(stride) must be >= width"); } int lastScanline = offset + (height - 1) * stride; int length = pixels.length; if (offset < 0 || (offset + width > length) || lastScanline < 0 || (lastScanline + width > length)) { throw new ArrayIndexOutOfBoundsException(); } }

研究了哈源代碼發現問題出在resizeImage(mBitmap, width, height);這個方法調用里面,原有方法:

<span style="color:#333333;"> public static Bitmap resizeImage(Bitmap bitmap, int w, int h) { Bitmap BitmapOrg = bitmap; int width = BitmapOrg.getWidth(); int height = BitmapOrg.getHeight(); int newWidth = w; int newHeight = h; </span><span style="color:#ff0000;">float scaleWidth = newWidth / width; float scaleHeight = newHeight / height;</span><span style="color:#333333;"> Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width, height, matrix, true); return resizedBitmap; }</span>

這里計算的單位換算 float=int/int>>>float=int*1.0f/int就不會報錯了,否則平板上會報錯



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 毛片a区| 老王午夜69精品影院 | 最近高清中文字幕大全1 | 亚洲人成综合网站在线 | 国内成人自拍 | 日本a∨在线播放高清 | 99久久精品国产一区二区三区 | 精品视频在线观看 | 国产精品网站在线观看 | 日本成人免费在线视频 | 精品精品国产高清a毛片 | 一国产一级淫片a免费播放口 | 国产精品一区二 | 超刺激福利丝袜网站 | 亚洲人成伊人成综合网久久久 | 欧美性网站 | 国产视频日本 | 久久好色| 国产免费福利 | 欧美精| 久草在线播放视频 | 92看片淫黄大片欧美看国产片 | 亚洲图片天堂 | 久久精品桃花综合 | 久久精品国产视频在热 | 欧美日韩国产高清一区二区三区 | 中国精品久久 | 91精品国产人成网站 | 男女最猛烈xx00动态视频 | asmr国产一区在线 | 波多野结衣不卡 | 精品一区二区三区高清免费观看 | 一级aa毛片| 日本久久综合视频 | 99精品国产成人a∨免费看 | 国产日韩精品欧美一区色 | 亚洲综合三区 | 春色视频网站 | 女人18一级特级毛片免费看 | 欧美在线看片 | 久久亚洲精品中文字幕三区 |