예제 #1
0
파일: gwin.c 프로젝트: bunnie/uGFX
void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
	if (!((gh->flags & GWIN_FLG_VISIBLE)))
		return;

	#if GDISP_NEED_CLIP
		gdispSetClip(gh->x, gh->y, gh->width, gh->height);
	#endif
	gdispBlitAreaEx(gh->x+x, gh->y+y, cx, cy, srcx, srcy, srccx, buffer);
}
예제 #2
0
gdispImageError gdispImageDraw_NATIVE(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy) {
    coord_t		mx, mcx;
    size_t		pos, len;

    /* Check some reasonableness */
    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 from the image cache - if it exists */
    if (img->priv->frame0cache) {
        gdispBlitAreaEx(x, y, cx, cy, sx, sy, img->width, img->priv->frame0cache);
        return GDISP_IMAGE_ERR_OK;
    }

    /* For this image decoder we cheat and just seek straight to the region we want to display */
    pos = FRAME0POS + (img->width * sy + cx) * sizeof(pixel_t);

    /* Cycle through the lines */
    for(; cy; cy--, y++) {
        /* Move to the start of the line */
        img->io.fns->seek(&img->io, pos);

        /* Draw the line in chunks using BitBlt */
        for(mx = x, mcx = cx; mcx > 0; mcx -= len, mx += len) {
            // Read the data
            len = img->io.fns->read(&img->io,
                                    img->priv->buf,
                                    mx > BLIT_BUFFER_SIZE ? (BLIT_BUFFER_SIZE*sizeof(pixel_t)) : (mx * sizeof(pixel_t)))
                  / sizeof(pixel_t);
            if (!len)
                return GDISP_IMAGE_ERR_BADDATA;

            /* Blit the chunk of data */
            gdispBlitAreaEx(mx, y, len, 1, 0, 0, len, img->priv->buf);
        }

        /* Get the position for the start of the next line */
        pos += img->width*sizeof(pixel_t);
    }

    return GDISP_IMAGE_ERR_OK;
}