(ByteBuffer inbuf,
PixelFormat pf, ByteBuffer outbuf,
int stride, Rect r)
| 408 | } |
| 409 | |
| 410 | final private void FilterGradient24(ByteBuffer inbuf, |
| 411 | PixelFormat pf, ByteBuffer outbuf, |
| 412 | int stride, Rect r) |
| 413 | { |
| 414 | int x, y, c; |
| 415 | byte[] prevRow = new byte[TIGHT_MAX_WIDTH*3]; |
| 416 | byte[] thisRow = new byte[TIGHT_MAX_WIDTH*3]; |
| 417 | ByteBuffer pix = ByteBuffer.allocate(3); |
| 418 | int[] est = new int[3]; |
| 419 | |
| 420 | // Set up shortcut variables |
| 421 | int rectHeight = r.height(); |
| 422 | int rectWidth = r.width(); |
| 423 | |
| 424 | for (y = 0; y < rectHeight; y++) { |
| 425 | for (x = 0; x < rectWidth; x++) { |
| 426 | /* First pixel in a row */ |
| 427 | if (x == 0) { |
| 428 | for (c = 0; c < 3; c++) { |
| 429 | pix.put(c, (byte)(inbuf.get(y*rectWidth*3+c) + prevRow[c])); |
| 430 | thisRow[c] = pix.get(c); |
| 431 | } |
| 432 | pf.bufferFromRGB((ByteBuffer)outbuf.duplicate().position(y*stride), pix, 1); |
| 433 | continue; |
| 434 | } |
| 435 | |
| 436 | for (c = 0; c < 3; c++) { |
| 437 | est[c] = prevRow[x*3+c] + pix.get(c) - prevRow[(x-1)*3+c]; |
| 438 | if (est[c] > 0xff) { |
| 439 | est[c] = 0xff; |
| 440 | } else if (est[c] < 0) { |
| 441 | est[c] = 0; |
| 442 | } |
| 443 | pix.put(c, (byte)(inbuf.get((y*rectWidth+x)*3+c) + est[c])); |
| 444 | thisRow[x*3+c] = pix.get(c); |
| 445 | } |
| 446 | pf.bufferFromRGB((ByteBuffer)outbuf.duplicate().position(y*stride+x), pix, 1); |
| 447 | } |
| 448 | |
| 449 | System.arraycopy(thisRow, 0, prevRow, 0, prevRow.length); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | final private void FilterGradient(ByteBuffer inbuf, |
| 454 | PixelFormat pf, ByteBuffer outbuf, |
no test coverage detected