MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_poco_drawBitmap

Function xs_poco_drawBitmap

modules/commodetto/commodettoPocoCore.c:662–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662void xs_poco_drawBitmap(xsMachine *the)
663{
664 Poco poco = xsmcGetHostDataPoco(xsThis);
665 int argc = xsmcArgc;
666 PocoBitmapRecord bits;
667 PocoCoordinate x, y;
668 PocoDimension sx, sy, sw, sh;
669 CommodettoBitmap cb;
670
671 cb = xsmcGetHostChunk(xsArg(0));
672 bits.width = cb->w;
673 bits.height = cb->h;
674 bits.format = cb->format;
675#if COMMODETTO_BITMAP_ID
676 bits.id = cb->id;
677 bits.byteLength = cb->byteLength;
678#endif
679 bits.pixels = pocoGetBitmapPixels(the, poco, cb, 0);
680
681 x = (PocoCoordinate)xsmcToInteger(xsArg(1)) + poco->xOrigin;
682 y = (PocoCoordinate)xsmcToInteger(xsArg(2)) + poco->yOrigin;
683
684 if (argc <= 3) {
685 sx = 0, sy = 0;
686#if (90 == kPocoRotation) || (270 == kPocoRotation)
687 sw = bits.height, sh = bits.width;
688#else
689 sw = bits.width, sh = bits.height;
690#endif
691 }
692 else {
693 sx = (PocoDimension)xsmcToInteger(xsArg(3));
694 sy = (PocoDimension)xsmcToInteger(xsArg(4));
695 sw = (PocoDimension)xsmcToInteger(xsArg(5));
696 sh = (PocoDimension)xsmcToInteger(xsArg(6));
697#if (0 == kPocoRotation) || (180 == kPocoRotation)
698 if ((sx >= bits.width) || (sy >= bits.height) || ((sx + sw) > bits.width) || ((sy + sh) > bits.height))
699#else
700 if ((sx >= bits.height) || (sy >= bits.width) || ((sx + sw) > bits.height) || ((sy + sh) > bits.width))
701#endif
702 xsRangeError("invalid src");
703 }
704
705 PocoBitmapDraw(poco, &bits, x, y, sx, sy, sw, sh);
706}
707
708void xs_poco_drawMonochrome(xsMachine *the)
709{

Callers

nothing calls this directly

Calls 2

pocoGetBitmapPixelsFunction · 0.85
PocoBitmapDrawFunction · 0.85

Tested by

no test coverage detected