Creates new frame image from current data (and previous frames as specified by their disposition codes).
()
| 650 | * frames as specified by their disposition codes). |
| 651 | */ |
| 652 | private void setPixels() { |
| 653 | |
| 654 | // expose destination image's pixels as int array |
| 655 | int[] dest = (int[]) image.getPixels(); |
| 656 | |
| 657 | // fill in starting image contents based on last image's dispose code (if any) |
| 658 | if (lastDispose > 0) { |
| 659 | if (lastDispose == 3) { // use image before last |
| 660 | int n = frameCount - 2; |
| 661 | if (n > 0) |
| 662 | lastImage = getFrame(n-1); |
| 663 | else |
| 664 | lastImage = null; |
| 665 | } |
| 666 | |
| 667 | if (lastImage != null) { |
| 668 | int[] prev = (int[]) lastImage.getPixels(); |
| 669 | System.arraycopy(prev, 0, dest, 0, width*height); // copy pixels |
| 670 | |
| 671 | if ((lastDispose == 2) && (lastBgColor != 0)) { |
| 672 | // fill last image rect area with background color |
| 673 | image.setColor(new Color(lastBgColor)); |
| 674 | image.setRoi(lastRect); |
| 675 | image.fill(); |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | // copy each source line to the appropriate place in the destination |
| 681 | int pass = 1; |
| 682 | int inc = 8; |
| 683 | int iline = 0; |
| 684 | for (int i = 0; i < ih; i++) { |
| 685 | int line = i; |
| 686 | if (interlace) { |
| 687 | if (iline >= ih) { |
| 688 | pass++; |
| 689 | switch (pass) { |
| 690 | case 2: |
| 691 | iline = 4; |
| 692 | break; |
| 693 | case 3: |
| 694 | iline = 2; |
| 695 | inc = 4; |
| 696 | break; |
| 697 | case 4: |
| 698 | iline = 1; |
| 699 | inc = 2; |
| 700 | } |
| 701 | } |
| 702 | line = iline; |
| 703 | iline += inc; |
| 704 | } |
| 705 | line += iy; |
| 706 | if (line < height) { |
| 707 | int k = line * width; |
| 708 | int dx = k + ix; // start of line in dest |
| 709 | int dlim = dx + iw; // end of dest line |
no test coverage detected