| 667 | } |
| 668 | |
| 669 | void PocoGrayBitmapDraw(Poco poco, PocoBitmap bits, PocoColor color, uint8_t blend, PocoCoordinate x, PocoCoordinate y, PocoDimension sx, PocoDimension sy, PocoDimension sw, PocoDimension sh) |
| 670 | { |
| 671 | PocoCommand pc = poco->next; |
| 672 | int16_t d; |
| 673 | |
| 674 | if (kCommodettoBitmapGray16 != (bits->format & ~kCommodettoBitmapPacked)) { |
| 675 | if (kCommodettoBitmapMonochrome == bits->format) |
| 676 | PocoMonochromeBitmapDraw(poco, bits, kPocoMonochromeForeground, color, color, x, y, sx, sy, sw, sh); |
| 677 | return; |
| 678 | } |
| 679 | |
| 680 | PocoReturnIfNoSpace(pc, sizeof(RenderGray16BitsRecord)); |
| 681 | |
| 682 | rotateCoordinates(poco->width, poco->height, x, y, sw, sh); |
| 683 | #if (0 == kPocoRotation) || (180 == kPocoRotation) |
| 684 | rotateCoordinatesAndDimensions(bits->width, bits->height, sx, sy, sw, sh); |
| 685 | #elif (90 == kPocoRotation) || (270 == kPocoRotation) |
| 686 | rotateCoordinatesAndDimensions(bits->height, bits->width, sx, sy, sw, sh); |
| 687 | #endif |
| 688 | if ((x >= poco->xMax) || (y >= poco->yMax) || (0 == blend)) |
| 689 | return; |
| 690 | |
| 691 | if (x < poco->x) { |
| 692 | d = poco->x - x; |
| 693 | if (sw <= d) |
| 694 | return; |
| 695 | sx += d; |
| 696 | sw -= d; |
| 697 | x = poco->x; |
| 698 | } |
| 699 | |
| 700 | if (y < poco->y) { |
| 701 | d = poco->y - y; |
| 702 | if (sh <= d) |
| 703 | return; |
| 704 | sy += d; |
| 705 | sh -= d; |
| 706 | y = poco->y; |
| 707 | } |
| 708 | |
| 709 | if ((x + sw) > poco->xMax) |
| 710 | sw = poco->xMax - x; |
| 711 | |
| 712 | if ((y + sh) > poco->yMax) |
| 713 | sh = poco->yMax - y; |
| 714 | |
| 715 | if ((sx >= bits->width) || (sy >= bits->height) || ((sx + sw) > bits->width) || ((sy + sh) > bits->height) || !sw || !sh) |
| 716 | return; |
| 717 | |
| 718 | pc->x = x, pc->y = y, pc->w = sw, pc->h = sh; |
| 719 | |
| 720 | if (!(bits->format & kCommodettoBitmapPacked)) { |
| 721 | RenderGray16Bits srcBits; |
| 722 | const PocoPixel *pixels = bits->pixels; |
| 723 | |
| 724 | pixels = (PocoPixel *)(((char *)pixels) + ((bits->width >> 1) * sy)); // clipped off top. skip sy scan lines. |
| 725 | pixels = (PocoPixel *)(((char *)pixels) + (sx >> 1)); |
| 726 |
no test coverage detected