(ByteBuffer inbuf,
PixelFormat pf, ByteBuffer outbuf,
int stride, Rect r)
| 451 | } |
| 452 | |
| 453 | final private void FilterGradient(ByteBuffer inbuf, |
| 454 | PixelFormat pf, ByteBuffer outbuf, |
| 455 | int stride, Rect r) |
| 456 | { |
| 457 | int x, y, c; |
| 458 | byte[] prevRow = new byte[TIGHT_MAX_WIDTH*3]; |
| 459 | byte[] thisRow = new byte[TIGHT_MAX_WIDTH*3]; |
| 460 | ByteBuffer pix = ByteBuffer.allocate(3); |
| 461 | int[] est = new int[3]; |
| 462 | |
| 463 | // Set up shortcut variables |
| 464 | int rectHeight = r.height(); |
| 465 | int rectWidth = r.width(); |
| 466 | |
| 467 | for (y = 0; y < rectHeight; y++) { |
| 468 | for (x = 0; x < rectWidth; x++) { |
| 469 | /* First pixel in a row */ |
| 470 | if (x == 0) { |
| 471 | pf.rgbFromBuffer(pix.duplicate(), (ByteBuffer)inbuf.position(y*rectWidth), 1); |
| 472 | for (c = 0; c < 3; c++) |
| 473 | pix.put(c, (byte)(pix.get(c) + prevRow[c])); |
| 474 | |
| 475 | System.arraycopy(pix.array(), 0, thisRow, 0, pix.capacity()); |
| 476 | pf.bufferFromRGB((ByteBuffer)outbuf.duplicate().position(y*stride), pix, 1); |
| 477 | continue; |
| 478 | } |
| 479 | |
| 480 | for (c = 0; c < 3; c++) { |
| 481 | est[c] = prevRow[x*3+c] + pix.get(c) - prevRow[(x-1)*3+c]; |
| 482 | if (est[c] > 0xff) { |
| 483 | est[c] = 0xff; |
| 484 | } else if (est[c] < 0) { |
| 485 | est[c] = 0; |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | pf.rgbFromBuffer(pix.duplicate(), (ByteBuffer)inbuf.position(y*rectWidth+x), 1); |
| 490 | for (c = 0; c < 3; c++) |
| 491 | pix.put(c, (byte)(pix.get(c) + est[c])); |
| 492 | |
| 493 | System.arraycopy(pix.array(), 0, thisRow, x*3, pix.capacity()); |
| 494 | |
| 495 | pf.bufferFromRGB((ByteBuffer)outbuf.duplicate().position(y*stride+x), pix, 1); |
| 496 | } |
| 497 | |
| 498 | System.arraycopy(thisRow, 0, prevRow, 0, prevRow.length); |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | private void FilterPalette8(ByteBuffer palette, int palSize, |
| 503 | ByteBuffer inbuf, ByteBuffer outbuf, |
no test coverage detected