本文整理汇总了C++中draw_image函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_image函数的具体用法?C++ draw_image怎么用?C++ draw_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_exit_menu
void render_exit_menu(exit_menu_t *state, float cursor_x, float cursor_y)
{
// Update center of cursor
set_cursor_position(state->cursor_state, cursor_x, cursor_y);
// Check if anything selected
check_cursor_in_image(state->cursor_state, state->mandelbrot_state);
check_cursor_in_image(state->cursor_state, state->sph_state);
check_cursor_in_image(state->cursor_state, state->terminal_state);
// Draw background rectangle
float center[2] = {0.0f, 0.0f};
float gl_dims[2] = {2.0f, 0.7f};
float background_color[4] = {1.0f, 1.0f, 1.0f, 0.8f};
render_rectangle(state->rectangle_state, center, gl_dims, background_color);
// Draw mandelbrot image
draw_image(state->mandelbrot_state);
// Draw terminal image
draw_image(state->terminal_state);
// Draw SPH image
draw_image(state->sph_state);
// Draw cursor
draw_cursor(state->cursor_state);
}
示例2: main
int main (int argc, char **argv) {
SDL_Surface *screen = NULL;
SDL_Window *window = NULL;
if (startup("Space Shooter")) {
SDL_Surface *background = load_image("assets/background.png");
SDL_Surface *ship = load_image("assets/captain.png");
draw_image(background, 0, 0);
draw_image(ship, 100, 100);
SDL_UpdateWindowSurface(g_window);
#if __EMSCRIPTEN__
#else
SDL_Delay(5000);
#endif
SDL_FreeSurface(background);
SDL_FreeSurface(ship);
}
else {
printf("Could not initialise SDL\n");
}
SDL_DestroyWindow(g_window);
SDL_Quit();
return 0;
}
示例3: draw_pipe
/* draw_pipe - draws all active pipes on the screen */
void draw_pipe() {
int i, j, len = 0, actives[MAX_PIPES], offset = 12, bottom_height, cur_ind;
for (i = 0; i < MAX_PIPES; i++)
if (pipes[i].active)
actives[len++] = i;
for (j = 0; j < len; j++) {
cur_ind = actives[j];
bottom_height = (GROUND_HEIGHT - offset - (PIPE_GAP +
pipes[cur_ind].height * pipes[cur_ind].pipe->h)) / pipes[cur_ind].pipe->h;
for (i = 0; i < pipes[cur_ind].height - 2; i++) {
draw_image(pipes[cur_ind].pipe, pipes[cur_ind].x, i * pipes[cur_ind].pipe->h);
}
for (i = pipes[cur_ind].height - 2; i <= pipes[cur_ind].height; i++) {
draw_image(pipes[cur_ind].pipe_top, pipes[cur_ind].x - 2, i * pipes[cur_ind].pipe->h - 1);
}
for (i = 0; i < bottom_height - 2; i++) {
draw_image(pipes[cur_ind].pipe, pipes[cur_ind].x,
GROUND_HEIGHT - offset - i * pipes[cur_ind].pipe->h);
}
for (i = bottom_height - 2; i <= bottom_height; i++) {
draw_image(pipes[cur_ind].pipe_top, pipes[cur_ind].x - 2,
GROUND_HEIGHT - offset - i * pipes[cur_ind].pipe->h - 1);
}
}
}
示例4: othello_color_draw
static void othello_color_draw(PzWidget *wid, ttk_surface srf)
{
unsigned char xline, yline, c;
int x, y, step, startx, endx, size;
#ifdef SDL
ttk_fillrect(srf, 0,0, wid->w, wid->h, ttk_ap_getx("window.bg")->color);
#endif
step = (wid->h / 8);
size = step * 8;
startx = (wid->w - wid->h) / 2;
endx = startx + size;
ttk_fillrect(srf, startx,0, endx, size, BGCOLOR);
for (x = 0; x < 9; ++x) {
int mod = (size / 8) * x;
ttk_line(srf, startx, mod, endx, mod, 0x000000);
ttk_line(srf, startx + mod, 0, startx + mod, size, 0x000000);
}
yline = 0;
for (c = 0; c < 64; c++) {
xline = c % 8;
x = xline * step + step/2 + startx;
y = yline * step + step/2 + 0;
if (_othello->b_set & (1ULL << c)) {
if (_othello->board & (1ULL << c))
draw_image(_othello->black, srf, x, y);
else
draw_image(_othello->white, srf, x, y);
}
else if (_othello->cur_bit == c)
draw_image(_othello->selection, srf, x, y);
if (xline == 7) yline++;
}
}
示例5: main
int main (int argc, char **argv)
{
HPDF_Doc pdf;
HPDF_Font font;
HPDF_Page page;
char fname[256];
HPDF_Destination dst;
strcpy (fname, argv[0]);
strcat (fname, ".pdf");
pdf = HPDF_New (error_handler, NULL);
if (!pdf) {
printf ("error: cannot create PdfDoc object\n");
return 1;
}
/* error-handler */
if (setjmp(env)) {
HPDF_Free (pdf);
return 1;
}
HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);
/* create default-font */
font = HPDF_GetFont (pdf, "Helvetica", NULL);
/* add a new page object. */
page = HPDF_AddPage (pdf);
HPDF_Page_SetWidth (page, 650);
HPDF_Page_SetHeight (page, 500);
dst = HPDF_Page_CreateDestination (page);
HPDF_Destination_SetXYZ (dst, 0, HPDF_Page_GetHeight (page), 1);
HPDF_SetOpenAction(pdf, dst);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, 20);
HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70);
HPDF_Page_ShowText (page, "JpegDemo");
HPDF_Page_EndText (page);
HPDF_Page_SetFontAndSize (page, font, 12);
draw_image (pdf, "rgb.jpg", 70, HPDF_Page_GetHeight (page) - 410,
"24bit color image");
draw_image (pdf, "gray.jpg", 340, HPDF_Page_GetHeight (page) - 410,
"8bit grayscale image");
/* save the document to a file */
HPDF_SaveToFile (pdf, fname);
/* clean up */
HPDF_Free (pdf);
return 0;
}
示例6: render_switcher
void render_switcher(struct desktop *desktops)
{
tile_image(theme->tile_img, switcher_pos, switcher_width);
if (!desktops)
return;
int ox = switcher_pos;
int limgw, rimgw;
ox += theme->switcher.space_gap;
uint state;
struct desktop *iter = desktops;
state = iter->focused ? BSTATE_PRESSED : BSTATE_IDLE;
if (!iter->next)
draw_switcher_alone(state, ox, iter->width);
else
draw_switcher_left_corner(state, ox, iter->width);
limgw = get_image_width(theme->switcher.left_corner_img[state]);
rimgw = get_image_width(theme->switcher.right_img[state]);
ox += limgw;
draw_text(theme->switcher.font, theme->switcher.text_align, ox, iter->width - limgw - rimgw,
theme->switcher.text_offset_x, theme->switcher.text_offset_y,
iter->name, &theme->switcher.text_color[state]);
ox += iter->width - limgw;
if (!iter->next)
return;
iter = iter->next;
state = iter->focused ? BSTATE_PRESSED : BSTATE_IDLE;
if (theme->switcher.separator_img) {
draw_image(theme->switcher.separator_img, ox);
ox += get_image_width(theme->switcher.separator_img);
}
limgw = get_image_width(theme->switcher.left_img[state]);
while (iter->next) {
draw_switcher_middle(state, ox, iter->width);
ox += limgw;
draw_text(theme->switcher.font, theme->switcher.text_align, ox, iter->width - limgw - rimgw,
theme->switcher.text_offset_x, theme->switcher.text_offset_y,
iter->name, &theme->switcher.text_color[state]);
ox += iter->width - limgw;
iter = iter->next;
state = iter->focused ? BSTATE_PRESSED : BSTATE_IDLE;
if (theme->switcher.separator_img) {
draw_image(theme->switcher.separator_img, ox);
ox += get_image_width(theme->switcher.separator_img);
}
}
rimgw = get_image_width(theme->switcher.right_corner_img[state]);
draw_switcher_right_corner(state, ox, iter->width);
ox += limgw;
draw_text(theme->switcher.font, theme->switcher.text_align, ox, iter->width - limgw - rimgw,
theme->switcher.text_offset_x, theme->switcher.text_offset_y,
iter->name, &theme->switcher.text_color[state]);
}
示例7: draw_image
void Active::draw()
{
bool blend = (active_flags & TRANSPARENT) || blend_color.a < 255 ||
effect != Render::NONE;
if (blend) {
draw_image(image, x, y, blend_color, angle, x_scale, y_scale);
return;
}
Render::disable_blend();
draw_image(image, x, y, blend_color, angle, x_scale, y_scale);
Render::enable_blend();
}
示例8: GetDC
void SWRenderDisplayWindowProvider::flip(int interval)
{
SWRenderGraphicContextProvider *gc_provider = static_cast<SWRenderGraphicContextProvider*>(gc.get_provider());
PixelCanvas *canvas = gc_provider->get_canvas();
#ifdef WIN32
HWND hwnd = window.get_hwnd();
HDC hdc = GetDC(hwnd);
draw_image(hdc, get_viewport(), canvas->to_pixelbuffer());
ReleaseDC(hwnd, hdc);
#elif !defined(__APPLE__)
PixelBuffer &image = canvas->to_pixelbuffer();
draw_image(get_viewport(), image, Rect(0, 0, image.get_width(), image.get_height()));
#endif
if (interval == -1)
interval = swap_interval; // use swap interval from the previous flip
else
swap_interval = interval;
if (interval<=0)
{
flip_timer_set = false;
}
else
{
if (!flip_timer_set)
{
flip_last_time = System::get_time();
flip_timer_set = true;
}
else
{
ubyte64 current_time = System::get_time();
int time_diff = current_time - flip_last_time;
interval *= 1000 / refresh_rate;
int time_wait = interval - time_diff;
if ( (time_wait > 0) && (time_wait < interval) )
{
System::sleep(time_wait);
flip_last_time = current_time + time_wait;
}
else
{
flip_last_time = current_time;
}
}
}
}
示例9: draw_image_P
//-----------------------------------------------------------------//
void monograph::draw_font(int16_t x, int16_t y, char code)
{
#ifdef KANJI_FONTS
if(multi_byte_hi_) {
uint8_t hi = multi_byte_hi_;
multi_byte_hi_ = 0;
if(-KANJI_FONT_WIDTH >= x || x >= fb_width_) return;
if(kanji_mode_ == 0) {
draw_image_P(x - FONT_WIDTH, y, &font6x12_[9 * 18], 6, 12);
draw_image_P(x, y, &font6x12_[9 * 19], 6, 12);
return;
}
const uint8_t* bitmap = scan_kanji_bitmap(hi, static_cast<uint8_t>(code));
if(bitmap != 0) {
draw_image(x - FONT_WIDTH, y, bitmap, KANJI_FONT_WIDTH, KANJI_FONT_HWIGHT);
} else {
uint8_t* bitmap = alloc_kanji_bitmap(hi, static_cast<uint8_t>(code));
uint16_t pos = sjis_to_liner(hi, static_cast<uint8_t>(code));
if(read_kanji_bitmap(pos, bitmap)) {
draw_image(x - FONT_WIDTH, y, bitmap, KANJI_FONT_WIDTH, KANJI_FONT_HEIGHT);
} else {
draw_image_P(x - FONT_WIDTH, y, &font6x12_[9 * 18], FONT_WIDTH, FONT_HEIGHT);
draw_image_P(x, y, &font6x12_[9 * 19], FONT_WIDTH, FONT_HEIGHT);
}
}
} else
#endif
{
#ifdef LCD128X64
if(code >= 0) {
if(-FONT_WIDTH >= x || static_cast<uint16_t>(x) >= fb_width_) {
return;
}
draw_image_P(x, y, &font6x12_[(code << 3) + code], FONT_WIDTH, FONT_HEIGHT);
} else if(static_cast<uint8_t>(code) >= 0x81
&& static_cast<uint8_t>(code) <= 0x9f) {
multi_byte_hi_ = code;
} else if(static_cast<uint8_t>(code) >= 0xe0
&& static_cast<uint8_t>(code) <= 0xef) {
multi_byte_hi_ = code;
} else {
// 無効キャラクターの意味として
multi_byte_hi_ = 0;
if(-FONT_WIDTH >= x || static_cast<uint16_t>(x) >= fb_width_) return;
draw_image_P(x, y, &font6x12_[(1 << 3)], FONT_WIDTH, FONT_HEIGHT);
}
#endif
}
}
示例10: before_title_in
/* **slide\_title\_in()**, **slide\_title\_out()** and
* **bling\_title()** are used by the level
* timeline to animate the title.
*
* We use cosine interpolation to slide the title in
* and out, creating a smoother effect.
*
* **progress** will hold a value between 0 to 1
* based on the event progess/duration, making it ideal
* for use with interpolation functions.
*/
static void* before_title_in(void* data, float elapsed_ms, float progress)
{
struct rectangle c = { 0, 0, 192, 108 };
struct rectangle r = { 0, 0, 64, 64 };
struct level_data* ldata = data;
UNUSED(elapsed_ms);
UNUSED(progress);
clear_image(ldata->title.mask, color_from_RGB(0, 0, 0));
draw_on_image(ldata->title.mask);
draw_image(ldata->title.spot, -15, 40, &r, 0);
draw_on_screen();
draw_image(ldata->title.mask, 0, 0, &c, 0);
return NULL;
}
示例11: show_scores
void show_scores()
{
int i=0;
char text_name[25];
char text_score[25];
TTF_Font *MyFont;
SDL_Color MyColor = {255,255,255};
SDL_Color MyColor2 = {255,0,0};
SDL_Surface *message = NULL;
MyFont = TTF_OpenFont("fonts\\sfont.ttf",20);
message = TTF_RenderText_Blended(MyFont,"TEAM NAMES",MyColor2);
draw_image(message,screen,NULL,150,170);
SDL_FreeSurface(message);
message = NULL;
message = TTF_RenderText_Blended(MyFont,"SCORES",MyColor2);
draw_image(message,screen,NULL,800,170);
SDL_FreeSurface(message);
message = NULL;
read_score();
sort_score();
for(i=0;i<10;++i)
{
strcpy(text_name,score[i].name);
message = TTF_RenderText_Blended(MyFont,text_name,MyColor);
draw_image(message,screen,NULL,150,200 + (30 * i));
SDL_FreeSurface(message);
message = NULL;
itoa(score[i].score,text_score,10);
message = TTF_RenderText_Blended(MyFont,text_score,MyColor);
draw_image(message,screen,NULL,800,200 + (30 * i));
SDL_FreeSurface(message);
message = NULL;
}
SDL_Flip(screen);
TTF_CloseFont(MyFont);
SDL_FreeSurface(message);
MyFont = NULL;
message = NULL;
}
示例12: apply_image
static void apply_image(GLenum texture, int image)
{
if (GL_has_multitexture && texture < GL_max_multitexture)
{
glActiveTextureARB(texture);
/* Always apply texture 0, but disable all other unused textures. */
if (texture == GL_TEXTURE0_ARB || image != 0)
draw_image(image);
else
glDisable(GL_TEXTURE_2D);
}
else draw_image(image);
}
示例13: draw_tile_sequence
static void draw_tile_sequence(Imlib_Image left, Imlib_Image tile, Imlib_Image right,
int ox, int width)
{
int lw = get_image_width(left);
int rw = get_image_width(right);
int tilew = width - lw - rw;
if (tilew < 0)
return;
draw_image(left, ox);
ox += lw;
tile_image(tile, ox, tilew);
ox += tilew;
draw_image(right, ox);
}
示例14: main
int main(int argc, char *argv[]) {
char *prog = argv[0];
int opt, rc=-1;
hex_t h;
utarray_new(cfg.hexv, &hex_icd);
while ( (opt = getopt(argc, argv, "v+i:o:h")) != -1) {
switch (opt) {
case 'v': cfg.verbose++; break;
case 'i': cfg.infile = strdup(optarg); break;
case 'o': cfg.outfile = strdup(optarg); break;
case 'h': default: usage(prog); break;
}
}
if (!cfg.outfile || !cfg.infile) usage(prog);
/* read input file */
tpl_node *tn = tpl_map("A(sii)", &h.id, &h.x, &h.y);
if (tpl_load(tn, TPL_FILE, cfg.infile)) goto done;
while(tpl_unpack(tn,1) > 0) utarray_push_back(cfg.hexv, &h);
tpl_free(tn);
find_bounds();
draw_image();
rc = 0;
done:
utarray_free(cfg.hexv);
return rc;
}
示例15: control
static int control(struct vo *vo, uint32_t request, void *data)
{
struct xvctx *ctx = vo->priv;
switch (request) {
case VOCTRL_GET_PANSCAN:
return VO_TRUE;
case VOCTRL_SET_PANSCAN:
resize(vo);
return VO_TRUE;
case VOCTRL_SET_EQUALIZER: {
vo->want_redraw = true;
struct voctrl_set_equalizer_args *args = data;
return xv_set_eq(vo, ctx->xv_port, args->name, args->value);
}
case VOCTRL_GET_EQUALIZER: {
struct voctrl_get_equalizer_args *args = data;
return xv_get_eq(vo, ctx->xv_port, args->name, args->valueptr);
}
case VOCTRL_REDRAW_FRAME:
draw_image(vo, ctx->original_image);
return true;
}
int events = 0;
int r = vo_x11_control(vo, &events, request, data);
if (events & (VO_EVENT_EXPOSE | VO_EVENT_RESIZE))
resize(vo);
vo_event(vo, events);
return r;
}