Andriod Bluetooth printing problems

Source: Internet
Author: User

Andriod Bluetooth printing problems

The following error occurs when you use a GPRS inter. jar on the Internet to develop a Bluetooth connection to the cash register: x + width must be <= bitmap. width ()

Zs errors are derived from matrix Detection:

 

 /**     * 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();        }    }

After studying the HA source code, we found that the problem lies in resizeImage (mBitmap, width, height). In this method call, the original method:

 

 

 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;    float scaleWidth = newWidth / width;    float scaleHeight = newHeight / height;    Matrix matrix = new Matrix();    matrix.postScale(scaleWidth, scaleHeight);    Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width,       height, matrix, true);    return resizedBitmap;  }

Here, the unit conversion float = int/int >>> float = int * 1.0f/int will not report an error. Otherwise, an error will be reported on the tablet.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.