gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, 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; gdispImagePrivate_NATIVE * priv; priv = (gdispImagePrivate_NATIVE *)img->priv; /* 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 (priv->frame0cache) { gdispGBlitArea(g, x, y, cx, cy, sx, sy, img->width, 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_NATIVE + (img->width * sy + sx) * sizeof(pixel_t); /* Cycle through the lines */ for(;cy;cy--, y++) { /* Move to the start of the line */ gfileSetPos(img->f, pos); /* Draw the line in chunks using BitBlt */ for(mx = x, mcx = cx; mcx > 0; mcx -= len, mx += len) { // Read the data len = gfileRead(img->f, priv->buf, mcx > BLIT_BUFFER_SIZE_NATIVE ? (BLIT_BUFFER_SIZE_NATIVE*sizeof(pixel_t)) : (mcx * sizeof(pixel_t))) / sizeof(pixel_t); if (!len) return GDISP_IMAGE_ERR_BADDATA; /* Blit the chunk of data */ gdispGBlitArea(g, mx, y, len, 1, 0, 0, len, priv->buf); } /* Get the position for the start of the next line */ pos += img->width*sizeof(pixel_t); } return GDISP_IMAGE_ERR_OK; }
bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* state) { (void)state; (void)animation; // Read the uGFX documentation for information how to use the displays // http://wiki.ugfx.org/index.php/Main_Page gdispClear(White); // You can use static variables for things that can't be found in the animation // or state structs, here we use the image //gdispGBlitArea is a tricky function to use since it supports blitting part of the image // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); return false; }