void font_blit(font_t *self, pixel_t *buf, int bufw, int bufh, const char *str, int dx, int dy ) { const char *p = str; int x = dx; int y = dy; int oldBlendMode = image_blendMode; int oldFlip = image_flip; image_blendMode = IMAGE_COLOR; image_flip = 0; while (*p) { if (*p == '\n') { x = dx; y += self->height; } else { stbtt_bakedchar *g = &self->glyphs[(int) (*p & 127)]; int w = g->x1 - g->x0; int h = g->y1 - g->y0; image_blit(&self->image, buf, bufw, bufh, x + g->xoff, y + g->yoff, g->x0, g->y0, w, h); x += g->xadvance; } p++; } image_blendMode = oldBlendMode; image_flip = oldFlip; }
void gfx_draw_image_section(const struct image *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, unsigned flags) { if (test_bit(flags, GFX_NO_CLIPPING)) { image_blit(image, src_x, src_y, src_w, src_h, gfx_back_buffer, dst_x, dst_y, flags & IMAGE_BLIT_MASK); } else { int cx = dst_x; int cy = dst_y; int cw = src_w; int ch = src_h; if (!gfx_clip(&cx, &cy, &cw, &ch)) return; int dx = (cx - dst_x); int dy = (cy - dst_y); image_blit(image, src_x + dx, src_y + dy, cw, ch, gfx_back_buffer, dst_x + dx, dst_y + dy, flags & IMAGE_BLIT_MASK); } }
/* creates the background */ image_t* create_background() { image_t* img = image_create(VIDEO_SCREEN_W, VIDEO_SCREEN_H); font_t *fnt = font_create("disclaimer"); v2d_t camera = v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2); image_clear(video_get_backbuffer(), image_rgb(0,0,0)); font_set_width(fnt, VIDEO_SCREEN_W - 6); font_set_text(fnt, "%s", text); font_set_position(fnt, v2d_new(3,3)); font_render(fnt, camera); image_blit(video_get_backbuffer(), img, 0, 0, 0, 0, image_width(img), image_height(img)); font_destroy(fnt); return img; }
void w_paint(window* pw, HWND hwnd, HDC hdc, RECT ri) { RECT rt; GetClientRect(hwnd, &rt); int view_w = rt.right - rt.left; int view_h = rt.bottom - rt.top; if( view_w != int(pw->buffer->pmap.width()) || view_h != int(pw->buffer->pmap.height()) ) { pw->buffer = new image(view_w,view_h); ri = rt; pw->dirty_area = agg::rect_i(rt.left, rt.top, rt.right, rt.bottom); } w_validate_buffer(pw,view_w,view_h); image_blit(hdc,ri.left, ri.top, pw->buffer.ptr(), ri.left, ri.top, ri.right - ri.left, ri.bottom - ri.top, false); }
/* * intro_render() * Renders the introduction scene */ void intro_render() { image_blit(bg, video_get_backbuffer(), 0, 0, (VIDEO_SCREEN_W - image_width(bg))/2, (VIDEO_SCREEN_H - image_height(bg))/2, image_width(bg), image_height(bg)); }