diff options
author | inmarket <andrewh@inmarket.com.au> | 2016-02-27 11:57:23 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2016-02-27 11:57:23 +1000 |
commit | 583b0226577b0ee1912f808d32c465ad1f38b3fa (patch) | |
tree | febc8996003a712b79bd7520fa08707cb9817466 /src/gdisp/gdisp_image.c | |
parent | ecc7f94c882a9f36538678cbc3ac941d7f518115 (diff) | |
download | uGFX-583b0226577b0ee1912f808d32c465ad1f38b3fa.tar.gz uGFX-583b0226577b0ee1912f808d32c465ad1f38b3fa.tar.bz2 uGFX-583b0226577b0ee1912f808d32c465ad1f38b3fa.zip |
Add PNG image support - Does not support interlaced PNG's
Diffstat (limited to 'src/gdisp/gdisp_image.c')
-rw-r--r-- | src/gdisp/gdisp_image.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gdisp/gdisp_image.c b/src/gdisp/gdisp_image.c index 853d2f75..356ba64f 100644 --- a/src/gdisp/gdisp_image.c +++ b/src/gdisp/gdisp_image.c @@ -154,6 +154,16 @@ gdispImageError gdispImageCache(gdispImage *img) { gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy) { if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT; + + // Check on window + if (cx <= 0 || cy <= 0) return GDISP_IMAGE_ERR_OK; + if (sx < 0) sx = 0; + if (sy < 0) sy = 0; + if (sx >= img->width || sy >= img->height) return GDISP_IMAGE_ERR_OK; + if (sx + cx > img->width) cx = img->width - sx; + if (sy + cy > img->height) cy = img->height - sy; + + // Draw return img->fns->draw(g, img, x, y, cx, cy, sx, sy); } |