androidbitmaptess-twoleptonica

How to efficiently convert an Android Bitmap to a Leptonica Pix?


I'm trying to convert a Bitmap to a Pix. However, manually reading every pixel from the Bitmap and setting it in the Pix is too slow.

Pix pix = new Pix(width, height, depth);
for (int x = 0; x < width; x++) {
    for (int y = 0; y < height; y++) {
        pix.setPixel(x, y, bmp.getPixel(x, y));
    }
}

Solution

  • Found the solution in the tess-two repo in ReadFile

    It is as easy as: Pix pix = ReadFile.readBitmap(bmp);