void _reload_loaded_bitmaps_delayed(void) { int flags = al_get_new_bitmap_flags(); int format = al_get_new_bitmap_format(); for (size_t i = 0; i < loaded_bitmaps.size(); i++) { MBITMAP *m = loaded_bitmaps[i]->bitmap; if ((loaded_bitmaps[i]->flags & ALLEGRO_NO_PRESERVE_TEXTURE) && loaded_bitmaps[i]->delayed) { al_set_new_bitmap_flags(loaded_bitmaps[i]->flags); al_set_new_bitmap_format(loaded_bitmaps[i]->format); if (loaded_bitmaps[i]->load_type == LOAD_LOAD) { m->bitmap = my_load_bitmap(loaded_bitmaps[i]->load.filename.c_str()); if (loaded_bitmaps[i]->load.redraw) { loaded_bitmaps[i]->load.redraw(m, loaded_bitmaps[i]->load.data); } } else { // create Recreate *d = &loaded_bitmaps[i]->recreate; m->bitmap = my_al_create_bitmap(d->w, d->h); if (d->func) { // recreate with func d->func(m, d->data); } } al_use_shader(NULL); } } al_set_new_bitmap_flags(flags); al_set_new_bitmap_format(format); }
MBITMAP *m_create_alpha_bitmap(int w, int h, void (*create)(MBITMAP *bitmap, RecreateData *), RecreateData *data, void (*destroy)(MBITMAP *b), bool delayed) // check { int f = al_get_new_bitmap_format(); al_set_new_bitmap_format(ALPHA_FMT); ALLEGRO_BITMAP *bitmap; int flags = al_get_new_bitmap_flags(); int new_flags = flags; if (config.getUseOnlyMemoryBitmaps()) { al_set_new_bitmap_flags(new_flags|ALLEGRO_MEMORY_BITMAP); bitmap = my_al_create_bitmap(w, h); } else { bitmap = my_al_create_bitmap(w, h); } al_set_new_bitmap_flags(flags); al_set_new_bitmap_format(f); MBITMAP *m = new_mbitmap(bitmap); if (create) { create(m, data); } #if defined ALLEGRO_ANDROID || defined ALLEGRO_WINDOWS if ( #ifdef ALLEGRO_WINDOWS (al_get_display_flags(display) & ALLEGRO_DIRECT3D) && #endif (al_get_bitmap_flags(bitmap) & ALLEGRO_NO_PRESERVE_TEXTURE) && !(al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) ) { LoadedBitmap *lb = new LoadedBitmap; null_lb(lb); lb->load_type = LOAD_CREATE; lb->flags = al_get_bitmap_flags(bitmap); lb->format = al_get_bitmap_format(bitmap); lb->destroy.func = destroy; lb->recreate.func = create; lb->recreate.data = data; lb->recreate.w = w; lb->recreate.h = h; lb->bitmap = m; lb->delayed = delayed; loaded_bitmaps.push_back(lb); } else { #endif if (data) { delete data; } #if defined ALLEGRO_ANDROID || defined ALLEGRO_WINDOWS } #endif return m; }
void m_draw_scaled_backbuffer(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, MBITMAP *dest) { ALLEGRO_BITMAP *old_target = al_get_target_bitmap(); int old_format = al_get_new_bitmap_format(); al_set_new_bitmap_format(al_get_bitmap_format(al_get_backbuffer(display))); MBITMAP *tmp = m_create_bitmap(sw, sh); int scr_w = al_get_display_width(display); int scr_h = al_get_display_height(display); if (sx+sw > scr_w) { sw = scr_w-sx; } else if (sx < 0) { sw -= sx; sx = 0; } if (sy+sh > scr_h) { sh = scr_h-sy; } else if (sy < 0) { sh -= sy; sy = 0; } #if defined ALLEGRO_RASPBERRYPI || defined ALLEGRO_IPHONE || defined ALLEGRO_ANDROID ALLEGRO_LOCKED_REGION *lr1 = al_lock_bitmap(tmp->bitmap, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY); ALLEGRO_LOCKED_REGION *lr2 = al_lock_bitmap_region( al_get_backbuffer(display), sx, sy, sw, sh, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY ); int pixel_size = al_get_pixel_size(al_get_bitmap_format(al_get_backbuffer(display))); for (int y = 0; y < sh; y++) { uint8_t *d1 = (uint8_t *)lr1->data + lr1->pitch * y; uint8_t *d2 = (uint8_t *)lr2->data + lr2->pitch * y; memcpy(d1, d2, pixel_size*sw); } al_unlock_bitmap(tmp->bitmap); al_unlock_bitmap(al_get_backbuffer(display)); #else m_set_target_bitmap(tmp); al_draw_bitmap_region(al_get_backbuffer(display), sx, sy, sw, sh, 0, 0, 0); #endif m_set_target_bitmap(dest); al_draw_scaled_bitmap( tmp->bitmap, 0, 0, sw, sh, dx, dy, dw, dh, 0 ); m_destroy_bitmap(tmp); al_set_target_bitmap(old_target); al_set_new_bitmap_format(old_format); }
MBITMAP *m_make_alpha_display_bitmap(MBITMAP *in) { int old = al_get_new_bitmap_format(); al_set_new_bitmap_format(ALPHA_FMT); MBITMAP *bmp = m_clone_bitmap(in); al_set_new_bitmap_format(old); m_destroy_bitmap(in); return bmp; }
bool Imgui_ImplA5_CreateDeviceObjects() { ImGuiIO &io = ImGui::GetIO(); // Build texture unsigned char *pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Create texture int flags = al_get_new_bitmap_flags(); int fmt = al_get_new_bitmap_format(); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE); ALLEGRO_BITMAP* img = al_create_bitmap(width, height); al_set_new_bitmap_flags(flags); al_set_new_bitmap_format(fmt); if (!img) return false; ALLEGRO_LOCKED_REGION *locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY); if (!locked_img) { al_destroy_bitmap(img); return false; } memcpy(locked_img->data, pixels, sizeof(int)*width*height); al_unlock_bitmap(img); // Convert software texture to hardware texture. ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(img); al_destroy_bitmap(img); if (!cloned_img) return false; // Store our identifier io.Fonts->TexID = (void*)cloned_img; g_Texture = cloned_img; // Cleanup (don't clear the input data if you want to append new fonts later) io.Fonts->ClearInputData(); io.Fonts->ClearTexData(); // Create an invisible mouse cursor // Because al_hide_mouse_cursor() seems to mess up with the actual inputs.. ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8); g_MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0); al_destroy_bitmap(mouse_cursor); return true; }
MBITMAP *m_load_alpha_bitmap(const char *name, bool force_memory) { ALLEGRO_BITMAP *bitmap = 0; int old = al_get_new_bitmap_format(); al_set_new_bitmap_format(ALPHA_FMT); if (!force_memory) bitmap = my_load_bitmap(name); if (!bitmap) { ALLEGRO_STATE s; al_store_state(&s, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); bitmap = my_load_bitmap(name); al_restore_state(&s); } al_set_new_bitmap_format(old); if (!bitmap) { return NULL; } MBITMAP *m = new_mbitmap(bitmap); #if defined ALLEGRO_ANDROID || defined ALLEGRO_WINDOWS if ( #ifdef ALLEGRO_WINDOWS (al_get_display_flags(display) & ALLEGRO_DIRECT3D) && #endif (al_get_bitmap_flags(bitmap) & ALLEGRO_NO_PRESERVE_TEXTURE) && !(al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) ) { LoadedBitmap *lb = new LoadedBitmap; null_lb(lb); lb->load_type = LOAD_LOAD; lb->flags = al_get_bitmap_flags(bitmap); lb->format = al_get_bitmap_format(bitmap); lb->load.filename = name; lb->load.redraw = NULL; lb->load.data = NULL; lb->bitmap = m; loaded_bitmaps.push_back(lb); } #endif return m; }
/* Converts a display bitmap to a memory bitmap preserving its contents. * Driver specific resources occupied by the display bitmap are freed. * A converted sub bitmap is invalid until its parent is converted. */ void _al_convert_to_memory_bitmap(ALLEGRO_BITMAP *bitmap) { ALLEGRO_BITMAP *tmp; ALLEGRO_STATE backup; size_t old_size; /* Do nothing if it is a memory bitmap already. */ if (bitmap->flags & ALLEGRO_MEMORY_BITMAP) return; if (bitmap->parent) { _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap); //al_realloc(bitmap, sizeof(ALLEGRO_BITMAP)); bitmap->display = NULL; bitmap->flags |= ALLEGRO_MEMORY_BITMAP; return; } ALLEGRO_DEBUG("converting display bitmap %p to memory bitmap\n", bitmap); /* Allocate a temporary bitmap which will hold the data * during the conversion process. */ al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(bitmap->format); tmp = _al_create_memory_bitmap(bitmap->w, bitmap->h); /* Preserve bitmap contents. */ al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_set_target_bitmap(tmp); al_draw_bitmap(bitmap, 0, 0, 0); tmp->cb_excl = bitmap->cb_excl; tmp->cr_excl = bitmap->cr_excl; tmp->cl = bitmap->cl; tmp->ct = bitmap->ct; al_restore_state(&backup); /* Destroy the display bitmap to free driver-specific resources. */ if (bitmap->vt) bitmap->vt->destroy_bitmap(bitmap); _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap); /* Do not shrink the bitmap object. This way we can convert back to the * display bitmap. */ /*al_realloc(bitmap, tmp->size); bitmap->size = tmp->size*/ /* Put the contents back to the bitmap. */ old_size = bitmap->size; memcpy(bitmap, tmp, tmp->size); bitmap->size = old_size; al_free(tmp); }
ALLEGRO_FONT *_al_load_bitmap_font(const char *fname, int size, int flags) { ALLEGRO_BITMAP *import_bmp; ALLEGRO_FONT *f; ALLEGRO_STATE backup; int range[2]; ASSERT(fname); (void)size; (void)flags; al_store_state(&backup, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); import_bmp = al_load_bitmap(fname); al_restore_state(&backup); if (!import_bmp) return NULL; /* We assume a single unicode range, starting at the space * character. */ range[0] = 32; range[1] = 32 + bitmap_font_count(import_bmp) - 1; f = al_grab_font_from_bitmap(import_bmp, 1, range); al_destroy_bitmap(import_bmp); return f; }
ALLEGRO_BITMAP_OGL* _al_ogl_create_backbuffer(ALLEGRO_DISPLAY *disp) { ALLEGRO_BITMAP_OGL *ogl_backbuffer; ALLEGRO_BITMAP *backbuffer; ALLEGRO_STATE backup; int format; ALLEGRO_DEBUG("Creating backbuffer\n"); al_store_state(&backup, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); // FIXME: _al_deduce_color_format would work fine if the display paramerers // are filled in, for WIZ and IPOD #ifdef ALLEGRO_GP2XWIZ format = ALLEGRO_PIXEL_FORMAT_RGB_565; /* Only support display format */ #elif defined ALLEGRO_IPHONE format = ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE; // TODO: This one is also supported //format = ALLEGRO_PIXEL_FORMAT_RGB_565; #else format = _al_deduce_color_format(&disp->extra_settings); /* Eww. No OpenGL hardware in the world does that - let's just * switch to some default. */ if (al_get_pixel_size(format) == 3) { /* Or should we use RGBA? Maybe only if not Nvidia cards? */ format = ALLEGRO_PIXEL_FORMAT_ABGR_8888; } #endif ALLEGRO_TRACE_CHANNEL_LEVEL("display", 1)("Deduced format %s for backbuffer.\n", _al_pixel_format_name(format)); /* Now that the display backbuffer has a format, update extra_settings so * the user can query it back. */ _al_set_color_components(format, &disp->extra_settings, ALLEGRO_REQUIRE); disp->backbuffer_format = format; ALLEGRO_DEBUG("Creating backbuffer bitmap\n"); al_set_new_bitmap_format(format); /* Using ALLEGRO_NO_PRESERVE_TEXTURE prevents extra memory being allocated */ al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP | ALLEGRO_NO_PRESERVE_TEXTURE); backbuffer = _al_ogl_create_bitmap(disp, disp->w, disp->h); al_restore_state(&backup); if (!backbuffer) { ALLEGRO_DEBUG("Backbuffer bitmap creation failed.\n"); return NULL; } ALLEGRO_TRACE_CHANNEL_LEVEL("display", 1)( "Created backbuffer bitmap (actual format: %s)\n", _al_pixel_format_name(backbuffer->format)); ogl_backbuffer = (ALLEGRO_BITMAP_OGL*)backbuffer; ogl_backbuffer->is_backbuffer = 1; backbuffer->display = disp; return ogl_backbuffer; }
void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp) { ALLEGRO_BITMAP *scaled_bmp; HICON icon, old_small, old_big; ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display; ALLEGRO_STATE backup; al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); scaled_bmp = al_create_bitmap(32, 32); al_set_target_bitmap(scaled_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb(255, 255, 255)); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, 32, 32, 0); al_restore_state(&backup); icon = _al_win_create_icon(win_display->window, scaled_bmp, 0, 0, false); old_small = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_SMALL, (LPARAM)icon); old_big = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_BIG, (LPARAM)icon); if (old_small) DestroyIcon(old_small); if (old_big) DestroyIcon(old_big); al_destroy_bitmap(scaled_bmp); }
bool BitmapResource::load(void) { al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); bitmap = al_load_bitmap(filename.c_str()); if (!bitmap) debug_message("Error loading bitmap %s\n", filename.c_str()); return bitmap != 0; }
/* Create an example bitmap. */ static ALLEGRO_BITMAP *create_example_bitmap(void) { ALLEGRO_BITMAP *raw; ALLEGRO_BITMAP *bitmap; int i, j; ALLEGRO_LOCKED_REGION *locked; unsigned char *data; /* Create out example bitmap as a memory bitmap with a fixed format. */ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888); raw = al_create_bitmap(100, 100); locked = al_lock_bitmap(raw, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY); data = locked->data; for (j = 0; j < 100; j++) { for (i = 0; i < 100; i++) { int x = i - 50, y = j - 50; int r = sqrt(x * x + y * y); float rc = 1 - r / 50.0; if (rc < 0) rc = 0; data[i * 4 + 0] = i * 255 / 100; data[i * 4 + 1] = j * 255 / 100; data[i * 4 + 2] = rc * 255; data[i * 4 + 3] = rc * 255; } data += locked->pitch; } al_unlock_bitmap(raw); /* Now clone it into a fast display bitmap. */ al_set_new_bitmap_flags(0); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); bitmap = al_clone_bitmap(raw); /* And don't forget to destroy the memory copy. */ al_destroy_bitmap(raw); return bitmap; }
void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp) { ALLEGRO_BITMAP *sm_bmp, *big_bmp; HICON sm_icon, big_icon, old_small, old_big; ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display; ALLEGRO_STATE backup; int sm_w, sm_h, big_w, big_h; al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); sm_w = GetSystemMetrics(SM_CXSMICON); sm_h = GetSystemMetrics(SM_CYSMICON); big_w = GetSystemMetrics(SM_CXICON); big_h = GetSystemMetrics(SM_CYICON); sm_bmp = al_create_bitmap(sm_w, sm_h); al_set_target_bitmap(sm_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, sm_w, sm_h, 0); big_bmp = al_create_bitmap(big_w, big_h); al_set_target_bitmap(big_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, big_w, big_h, 0); al_restore_state(&backup); sm_icon = _al_win_create_icon(win_display->window, sm_bmp, 0, 0, false, false); big_icon = _al_win_create_icon(win_display->window, big_bmp, 0, 0, false, false); old_small = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_SMALL, (LPARAM)sm_icon); old_big = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_BIG, (LPARAM)big_icon); if (old_small) DestroyIcon(old_small); if (old_big) DestroyIcon(old_big); al_destroy_bitmap(sm_bmp); al_destroy_bitmap(big_bmp); }
static void win_set_display_icon(ALLEGRO_DISPLAY_WIN *win_display, const WPARAM icon_type, const int sys_w, const int sys_h, const int num_icons, ALLEGRO_BITMAP *bmps[]) { HICON icon; HICON old_icon; ALLEGRO_BITMAP *bmp; int bmp_w; int bmp_h; int i; i = win_choose_icon_bitmap(sys_w, sys_h, num_icons, bmps); bmp = bmps[i]; bmp_w = al_get_bitmap_width(bmp); bmp_h = al_get_bitmap_height(bmp); if (bmp_w == sys_w && bmp_h == sys_h) { icon = _al_win_create_icon(win_display->window, bmp, 0, 0, false, false); } else { ALLEGRO_BITMAP *tmp_bmp; ALLEGRO_STATE backup; tmp_bmp = al_create_bitmap(sys_w, sys_h); if (!tmp_bmp) return; al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); al_set_target_bitmap(tmp_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bmp, 0, 0, bmp_w, bmp_h, 0, 0, sys_w, sys_h, 0); al_restore_state(&backup); icon = _al_win_create_icon(win_display->window, tmp_bmp, 0, 0, false, false); al_destroy_bitmap(tmp_bmp); } old_icon = (HICON)SendMessage(win_display->window, WM_SETICON, icon_type, (LPARAM)icon); if (old_icon) DestroyIcon(old_icon); }
int main(int argc, char **argv) { ALLEGRO_BITMAP *bitmap; double t0; double t1; if (!al_init()) { abort_example("Could not init Allegro.\n"); } open_log(); if (argc < 3) { log_printf("This example needs to be run from the command line.\n"); log_printf("Usage: %s <infile> <outfile>\n", argv[0]); log_printf("\tPossible file types: BMP PCX PNG TGA\n"); goto done; } al_init_image_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_NO_PREMULTIPLIED_ALPHA); bitmap = al_load_bitmap(argv[1]); if (!bitmap) { log_printf("Error loading input file\n"); goto done; } t0 = al_get_time(); if (!al_save_bitmap(argv[2], bitmap)) { log_printf("Error saving bitmap\n"); goto done; } t1 = al_get_time(); log_printf("Saving took %.4f seconds\n", t1 - t0); al_destroy_bitmap(bitmap); done: close_log(true); return 0; }
static void alloc_picture(VideoState *is) { VideoPicture *vp; vp = &is->pictq[is->pictq_windex]; if (vp->bmp) { // we already have one make another, bigger/smaller al_destroy_bitmap(vp->bmp); } al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_BGR_888); vp->bmp = al_create_bitmap(is->video_st->codec->width, is->video_st->codec->height); vp->width = is->video_st->codec->width; vp->height = is->video_st->codec->height; }
static ALLEGRO_BITMAP *push_new_page(ALLEGRO_TTF_FONT_DATA *data, int glyph_size) { ALLEGRO_BITMAP **back; ALLEGRO_BITMAP *page; ALLEGRO_STATE state; int page_size = 1; /* 16 seems to work well. A particular problem are fixed width fonts which * take an inordinate amount of space. */ while (page_size < 16 * glyph_size) { page_size *= 2; } if (page_size < data->min_page_size) { page_size = data->min_page_size; } if (page_size > data->max_page_size) { page_size = data->max_page_size; } if (glyph_size > page_size) { return NULL; } unlock_current_page(data); /* The bitmap will be destroyed when the parent font is destroyed so * it is not safe to register a destructor for it. */ _al_push_destructor_owner(); al_store_state(&state, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_format(data->bitmap_format); al_set_new_bitmap_flags(data->bitmap_flags); page = al_create_bitmap(page_size, page_size); al_restore_state(&state); _al_pop_destructor_owner(); if (page) { back = _al_vector_alloc_back(&data->page_bitmaps); *back = page; data->page_pos_x = 0; data->page_pos_y = 0; data->page_line_height = 0; } return page; }
int main(int argc, char **argv) { const char *if_name = argv[1]; const char *of_name = argv[2]; al_init(); al_init_image_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); ALLEGRO_BITMAP *i_bmp = al_load_bitmap(if_name); int w, h; w = al_get_bitmap_width(i_bmp); h = al_get_bitmap_height(i_bmp); ALLEGRO_BITMAP *o_bmp = al_create_bitmap(w, h); al_set_target_bitmap(o_bmp); al_clear_to_color(al_map_rgb(255, 0, 255)); int nanims = h/SUBH; int nframes = w/SUBW; for (int anim = 0; anim < nanims; anim++) { int f = SUBW-1; for (int i = 0; i < 4; i++) { ALLEGRO_BITMAP *sub = al_create_sub_bitmap(i_bmp, i*SUBW, anim*SUBH, SUBW, SUBH); int thisf = furthest_left(sub); if (thisf < SUBW-1 && thisf < f) f = thisf; al_destroy_bitmap(sub); } for (int i = 0; i < 4; i++) { ALLEGRO_BITMAP *sub = al_create_sub_bitmap(i_bmp, i*SUBW, anim*SUBH, SUBW, SUBH); al_draw_bitmap(sub, i*SUBW-(f/2), anim*SUBH, 0); al_destroy_bitmap(sub); } } al_save_bitmap(of_name, o_bmp); }
void Video_Player::get_frames(int num) { // Convert to video bitmaps for (int i = 0; i < num; i++) { ALLEGRO_STATE state; al_store_state(&state, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_format(General::noalpha_bmp_format); char buf[1000]; snprintf(buf, 1000, "%s/%06d.png", dirname.c_str(), total_frames_loaded+i); Wrap::Bitmap *b = Wrap::load_bitmap(buf); Video_Frame frame; frame.bitmap = b; frame.frame_num = total_frames_loaded + i; frames.push_back(frame); al_restore_state(&state); } total_frames_loaded += num; }
int main(int argc, char **argv) { ALLEGRO_BITMAP *bitmap; double t0; double t1; if (argc < 3) { fprintf(stderr, "Usage: exnew_convert <infile> <outfile>\n"); fprintf(stderr, "\tPossible file types: BMP PCX PNG TGA\n"); return 1; } if (!al_init()) { fprintf(stderr, "Could not init Allegro.\n"); return 1; } al_init_image_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_NO_PREMULTIPLIED_ALPHA); bitmap = al_load_bitmap(argv[1]); if (!bitmap) { fprintf(stderr, "Error loading input file\n"); return 1; } t0 = al_get_time(); if (!al_save_bitmap(argv[2], bitmap)) { fprintf(stderr, "Error saving bitmap\n"); return 1; } t1 = al_get_time(); printf("Saving took %.4f seconds\n", t1 - t0); al_destroy_bitmap(bitmap); return 0; }
bool init(void) { srand(time(NULL)); if (!al_init()) { debug_message("Error initialising Allegro.\n"); return false; } al_init_image_addon(); al_init_font_addon(); al_init_acodec_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); if (!loadResources()) { debug_message("Error loading resources.\n"); return false; } return true; }
// FIXME: Add a special case for when a single glyph rendering won't fit // into 256x256 pixels. static ALLEGRO_BITMAP *push_new_page(ALLEGRO_TTF_FONT_DATA *data) { ALLEGRO_BITMAP **back; ALLEGRO_BITMAP *page; ALLEGRO_STATE state; unlock_current_page(data); /* The bitmap will be destroyed when the parent font is destroyed so * it is not safe to register a destructor for it. */ _al_push_destructor_owner(); al_store_state(&state, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_format(data->bitmap_format); al_set_new_bitmap_flags(data->bitmap_flags); page = al_create_bitmap(256, 256); al_restore_state(&state); _al_pop_destructor_owner(); back = _al_vector_alloc_back(&data->page_bitmaps); *back = page; /* Sometimes OpenGL will partly sample texels from the border of * glyphs. So we better clear the texture to transparency. * XXX This is very slow and avoidable with some effort. */ al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP); al_hold_bitmap_drawing(false); al_set_target_bitmap(*back); al_clear_to_color(al_map_rgba_f(0, 0, 0, 0)); al_restore_state(&state); data->page_pos_x = 0; data->page_pos_y = 0; data->page_line_height = 0; return page; }
/* Function: al_grab_font_from_bitmap */ ALLEGRO_FONT *al_grab_font_from_bitmap(ALLEGRO_BITMAP *bmp, int ranges_n, const int ranges[]) { ALLEGRO_FONT *f; ALLEGRO_FONT_COLOR_DATA *cf, *prev = NULL; ALLEGRO_STATE backup; int i; ALLEGRO_COLOR mask = al_get_pixel(bmp, 0, 0); ALLEGRO_BITMAP *glyphs = NULL, *unmasked = NULL; int import_x = 0, import_y = 0; ALLEGRO_LOCKED_REGION *lock = NULL; int w, h; ASSERT(bmp); w = al_get_bitmap_width(bmp); h = al_get_bitmap_height(bmp); f = al_calloc(1, sizeof *f); f->vtable = &_al_font_vtable_color; al_store_state(&backup, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); unmasked = al_clone_bitmap(bmp); /* At least with OpenGL, texture pixels at the very border of * the glyph are sometimes partly sampled from the yellow mask * pixels. To work around this, we replace the mask with full * transparency. * And we best do it on a memory copy to avoid loading back a texture. */ al_convert_mask_to_alpha(unmasked, mask); al_restore_state(&backup); al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); // Use the users preferred format, so don't set this below! //al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); for (i = 0; i < ranges_n; i++) { int first = ranges[i * 2]; int last = ranges[i * 2 + 1]; int n = 1 + last - first; cf = al_calloc(1, sizeof(ALLEGRO_FONT_COLOR_DATA)); if (prev) prev->next = cf; else f->data = cf; cf->bitmaps = al_malloc(sizeof(ALLEGRO_BITMAP*) * n); cf->bitmaps[0] = NULL; if (!glyphs) { glyphs = al_clone_bitmap(unmasked); if (!glyphs) goto cleanup_and_fail_on_error; lock = al_lock_bitmap(bmp, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READONLY); } cf->glyphs = glyphs; if (import_bitmap_font_color(lock->data, lock->pitch, w, h, cf->bitmaps, cf->glyphs, n, &import_x, &import_y)) { goto cleanup_and_fail_on_error; } else { cf->begin = first; cf->end = last + 1; prev = cf; } } al_restore_state(&backup); cf = f->data; if (cf && cf->bitmaps[0]) f->height = al_get_bitmap_height(cf->bitmaps[0]); if (lock) al_unlock_bitmap(bmp); if (unmasked) al_destroy_bitmap(unmasked); f->dtor_item = _al_register_destructor(_al_dtor_list, "font", f, (void (*)(void *))al_destroy_font); return f; cleanup_and_fail_on_error: if (lock) al_unlock_bitmap(bmp); al_restore_state(&backup); al_destroy_font(f); if (unmasked) al_destroy_bitmap(unmasked); return NULL; }
int main(void) { ALLEGRO_THREAD *thread[NUM_THREADS]; ALLEGRO_DISPLAY *display; ALLEGRO_TIMER *timer; ALLEGRO_EVENT_QUEUE *queue; ALLEGRO_EVENT event; bool need_draw; int i; for (i = 0; i < 256; i++) { sin_lut[i] = 128 + (int) (127.0 * sin(i / 8.0)); } if (!al_init()) { abort_example("Could not init Allegro.\n"); return 1; } al_install_keyboard(); al_install_mouse(); display = al_create_display(W * IMAGES_PER_ROW, H * NUM_THREADS / IMAGES_PER_ROW); if (!display) { abort_example("Error creating display\n"); return 1; } timer = al_install_timer(1.0/3); if (!timer) { abort_example("Error creating timer\n"); return 1; } queue = al_create_event_queue(); if (!queue) { abort_example("Error creating event queue\n"); return 1; } al_register_event_source(queue, al_get_display_event_source(display)); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_mouse_event_source()); al_register_event_source(queue, al_get_timer_event_source(timer)); /* Note: * Right now, A5 video displays can only be accessed from the thread which * created them (at lesat for OpenGL). To lift this restriction, we could * keep track of the current OpenGL context for each thread and make all * functions accessing the display check for it.. not sure it's worth the * additional complexity though. */ al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_RGB_888); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); for (i = 0; i < NUM_THREADS; i++) { thread_info[i].bitmap = al_create_bitmap(W, H); if (!thread_info[i].bitmap) { goto Error; } thread_info[i].mutex = al_create_mutex(); if (!thread_info[i].mutex) { goto Error; } thread_info[i].cond = al_create_cond(); if (!thread_info[i].cond) { goto Error; } thread_info[i].is_paused = false; thread_info[i].random_seed = i; thread[i] = al_create_thread(thread_func, &thread_info[i]); if (!thread[i]) { goto Error; } } set_target(0, -0.56062033041600878303, -0.56064322926933807256); set_target(1, -0.57798076669230014080, -0.63449861991138123418); set_target(2, 0.36676836392830602929, -0.59081385302214906030); set_target(3, -1.48319283039401317303, -0.00000000200514696273); set_target(4, -0.74052910500707636032, 0.18340899525730713915); set_target(5, 0.25437906525768350097, -0.00046678223345789554); set_target(6, -0.56062033041600878303, 0.56064322926933807256); set_target(7, -0.57798076669230014080, 0.63449861991138123418); set_target(8, 0.36676836392830602929, 0.59081385302214906030); for (i = 0; i < NUM_THREADS; i++) { al_start_thread(thread[i]); } al_start_timer(timer); need_draw = true; while (true) { if (need_draw && al_event_queue_is_empty(queue)) { show_images(); need_draw = false; } al_wait_for_event(queue, &event); if (event.type == ALLEGRO_EVENT_TIMER) { need_draw = true; } else if (event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) { int n = (event.mouse.y / H) * IMAGES_PER_ROW + (event.mouse.x / W); if (n < NUM_THREADS) { double x = event.mouse.x - (event.mouse.x / W) * W; double y = event.mouse.y - (event.mouse.y / H) * H; /* Center to the mouse click position. */ if (thread_info[n].is_paused) { thread_info[n].target_x = x / W - 0.5; thread_info[n].target_y = y / H - 0.5; } toggle_pausedness(n); } } else if (event.type == ALLEGRO_EVENT_DISPLAY_EXPOSE) { need_draw = true; } else if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } else if (event.type == ALLEGRO_EVENT_KEY_DOWN) { if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { break; } need_draw = true; } } for (i = 0; i < NUM_THREADS; i++) { /* Set the flag to stop the thread. The thread might be waiting on a * condition variable, so signal the condition to force it to wake up. */ al_set_thread_should_stop(thread[i]); al_lock_mutex(thread_info[i].mutex); al_broadcast_cond(thread_info[i].cond); al_unlock_mutex(thread_info[i].mutex); /* al_destroy_thread() implicitly joins the thread, so this call is not * strictly necessary. */ al_join_thread(thread[i], NULL); al_destroy_thread(thread[i]); } al_destroy_event_queue(queue); al_uninstall_timer(timer); al_destroy_display(display); return 0; Error: return 1; }
static ALLEGRO_BITMAP *d3d_create_bitmap_from_surface(LPDIRECT3DSURFACE9 surface, int flags) { ALLEGRO_BITMAP *bitmap; ALLEGRO_BITMAP_D3D *d3d_bmp; D3DSURFACE_DESC desc; D3DLOCKED_RECT surf_locked_rect; D3DLOCKED_RECT sys_locked_rect; ALLEGRO_STATE backup; int format; unsigned int y; if (surface->GetDesc(&desc) != D3D_OK) { ALLEGRO_ERROR("d3d_create_bitmap_from_surface: GetDesc failed.\n"); return NULL; } if (surface->LockRect(&surf_locked_rect, 0, D3DLOCK_READONLY) != D3D_OK) { ALLEGRO_ERROR("d3d_create_bitmap_from_surface: LockRect failed.\n"); return NULL; } al_store_state(&backup, ALLEGRO_STATE_NEW_BITMAP_PARAMETERS); format = _al_d3d_format_to_allegro(desc.Format); al_set_new_bitmap_format(format); al_set_new_bitmap_flags(flags); bitmap = al_create_bitmap(desc.Width, desc.Height); d3d_bmp = (ALLEGRO_BITMAP_D3D *)bitmap; al_restore_state(&backup); if (!bitmap) { surface->UnlockRect(); return NULL; } if (d3d_bmp->system_texture->LockRect(0, &sys_locked_rect, 0, 0) != D3D_OK) { surface->UnlockRect(); al_destroy_bitmap(bitmap); ALLEGRO_ERROR("d3d_create_bitmap_from_surface: Lock system texture failed.\n"); return NULL; } for (y = 0; y < desc.Height; y++) { memcpy( ((char*)sys_locked_rect.pBits)+(sys_locked_rect.Pitch*y), ((char*)surf_locked_rect.pBits)+(surf_locked_rect.Pitch*y), desc.Width*4 ); } surface->UnlockRect(); d3d_bmp->system_texture->UnlockRect(0); if (d3d_bmp->display->device->UpdateTexture( (IDirect3DBaseTexture9 *)d3d_bmp->system_texture, (IDirect3DBaseTexture9 *)d3d_bmp->video_texture) != D3D_OK) { ALLEGRO_ERROR("d3d_create_bitmap_from_texture: Couldn't update texture.\n"); } return bitmap; }
static ALLEGRO_COLOR test(ALLEGRO_COLOR src_col, ALLEGRO_COLOR dst_col, ALLEGRO_COLOR blend, int src_format, int dst_format, int src, int dst, int src_a, int dst_a, int operation, bool verbose) { ALLEGRO_COLOR result; ALLEGRO_BITMAP *dst_bmp; al_set_new_bitmap_format(dst_format); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb_f(1, 1, 1)); dst_bmp = al_create_bitmap(1, 1); al_set_target_bitmap(dst_bmp); al_clear_to_color(dst_col); if (operation == 0) { ALLEGRO_BITMAP *src_bmp; al_set_new_bitmap_format(src_format); src_bmp = al_create_bitmap(1, 1); al_set_target_bitmap(src_bmp); al_clear_to_color(src_col); al_set_target_bitmap(dst_bmp); al_set_separate_blender(ALLEGRO_ADD, src, dst, ALLEGRO_ADD, src_a, dst_a, blend); al_draw_bitmap(src_bmp, 0, 0, 0); al_destroy_bitmap(src_bmp); } else if (operation == 1) { al_set_separate_blender(ALLEGRO_ADD, src, dst, ALLEGRO_ADD, src_a, dst_a, blend); al_draw_pixel(0, 0, src_col); } else if (operation == 2) { al_set_separate_blender(ALLEGRO_ADD, src, dst, ALLEGRO_ADD, src_a, dst_a, blend); al_draw_line(0, 0, 1, 1, src_col, 0); } result = al_get_pixel(dst_bmp, 0, 0); if (test_display) { al_set_target_bitmap(al_get_backbuffer()); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb_f(1, 1, 1)); al_draw_bitmap(dst_bmp, 0, 0, 0); } al_destroy_bitmap(dst_bmp); if (!verbose) return result; printf("---\n"); printf("test id: %d\n", test_index); printf("source : "); print_color(src_col); printf(" %s format=%d mode=%d alpha=%d\n", operation == 0 ? "bitmap" : operation == 1 ? "pixel" : "prim", src_format, src, src_a); printf("destination: "); print_color(dst_col); printf(" format=%d mode=%d alpha=%d\n", dst_format, dst, dst_a); printf("blender : "); print_color(blend); printf("\n"); printf("result : "); print_color(result); printf("\n"); return result; }
int main(int argc, char **argv) { if (argc < 3) { printf("Usage: infile.png outfile.png\n"); return 0; } al_init(); al_init_image_addon(); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); ALLEGRO_BITMAP *inbmp = al_load_bitmap(argv[1]); al_set_target_bitmap(inbmp); int x, y; for (y = 0; y < al_get_bitmap_height(inbmp);) { for (x = 0; x < al_get_bitmap_width(inbmp); x++) { ALLEGRO_COLOR pixel = al_get_pixel(inbmp, x, y); if (pixel.a == 0) { int h = 1; do { ALLEGRO_COLOR p = al_get_pixel(inbmp, x, y+h); if (p.a == 0 || (p.r == 1 && p.g == 1 && p.b == 1)) h++; else break; } while (1); printf("h=%d\n", h); for (int r = 0; r < h; r++) { ALLEGRO_COLOR c; if (r < h/2) { float p = (float)r / (h/2); int diff = MIDDLE-TOP; int v = diff*p + TOP; c = al_map_rgb(v, v, v); printf("v=%d\n", v); } else { float p = 1 - ((float)(r-h/2) / (h/2)); int diff = MIDDLE-TOP; int v = diff*p + TOP; c = al_map_rgb(v, v, v); printf("v=%d\n", v); } for (int xx = 0; xx < al_get_bitmap_width(inbmp); xx++) { ALLEGRO_COLOR p = al_get_pixel(inbmp, xx, y+r); if (p.r == 1 && p.g == 1 && p.b == 1 && p.a == 1) { al_put_pixel(xx, y+r, c); } } } y += h+1; goto loop; } } y++; loop:; } al_save_bitmap(argv[2], inbmp); }
void Prog::draw_sample() { const int i = source_list.get_cur_value(); const int j = dest_list.get_cur_value(); ALLEGRO_BITMAP *bitmap1; ALLEGRO_BITMAP *bitmap2; bool use_memory = use_memory_button.get_pushed(); bool enable_timing = enable_timing_button.get_pushed(); if (use_memory) al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); else al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); al_set_new_bitmap_format(formats[i].format); bitmap1 = al_load_bitmap("data/allegro.pcx"); if (!bitmap1) { printf("Could not load image, bitmap format = %d\n", formats[i].format); } al_set_new_bitmap_format(formats[j].format); bitmap2 = al_create_bitmap(320, 200); if (!bitmap2) { printf("Could not create bitmap, format = %d\n", formats[j].format); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (bitmap1 && bitmap2) { ALLEGRO_BITMAP *target = al_get_target_bitmap(); al_set_target_bitmap(bitmap2); if (enable_timing) { double t0, t1; char str[256]; int frames = 0; t0 = al_get_time(); printf("Timing...\n"); do { al_draw_bitmap(bitmap1, 0, 0, 0); frames++; t1 = al_get_time(); } while (t1 - t0 < 0.25); printf(" ...done.\n"); sprintf(str, "%.0f FPS", (double)frames / (t1 - t0)); time_label.set_text(str); } else { al_draw_bitmap(bitmap1, 0, 0, 0); time_label.set_text(""); } al_set_target_bitmap(target); al_draw_bitmap(bitmap2, 0, 0, 0); } else { al_draw_line(0, 0, 320, 200, al_map_rgb_f(1, 0, 0), 0); al_draw_line(0, 200, 320, 0, al_map_rgb_f(1, 0, 0), 0); } std::string s = get_format_name(bitmap1); s += " -> "; s += get_format_name(bitmap2); true_formats.set_text(s); al_destroy_bitmap(bitmap1); al_destroy_bitmap(bitmap2); }
static void draw(void) { float x, y; int cx, cy, cw, ch; int w = al_get_bitmap_width(ex.zoom); int h = al_get_bitmap_height(ex.zoom); ALLEGRO_BITMAP *screen = al_get_target_bitmap(); ALLEGRO_BITMAP *mem; int rects_num = 16, i, j; float rects[16 * 4]; for (j = 0; j < 4; j++) { for (i = 0; i < 4; i++) { rects[(j * 4 + i) * 4 + 0] = 2 + i * 0.25 + i * 7; rects[(j * 4 + i) * 4 + 1] = 2 + j * 0.25 + j * 7; rects[(j * 4 + i) * 4 + 2] = 2 + i * 0.25 + i * 7 + 5; rects[(j * 4 + i) * 4 + 3] = 2 + j * 0.25 + j * 7 + 5; } } al_get_clipping_rectangle(&cx, &cy, &cw, &ch); al_clear_to_color(ex.background); set_xy(8, 0); print("Drawing %s (press SPACE to change)", names[ex.what]); set_xy(8, 16); print("Original"); set_xy(80, 16); print("Enlarged x 16"); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (ex.software) { al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(al_get_bitmap_format(al_get_target_bitmap())); mem = al_create_bitmap(w, h); al_set_target_bitmap(mem); x = 0; y = 0; } else { mem = NULL; x = 8; y = 40; } al_draw_bitmap(ex.pattern, x, y, 0); /* Draw the test scene. */ al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); for (i = 0; i < rects_num; i++) { ALLEGRO_COLOR rgba = ex.foreground; rgba.a *= 0.5; primitive( x + rects[i * 4 + 0], y + rects[i * 4 + 1], x + rects[i * 4 + 2], y + rects[i * 4 + 3], rgba, false); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (ex.software) { al_set_target_bitmap(screen); x = 8; y = 40; al_draw_bitmap(mem, x, y, 0); al_destroy_bitmap(mem); } /* Grab screen contents into our bitmap. */ al_set_target_bitmap(ex.zoom); al_draw_bitmap_region(screen, x, y, w, h, 0, 0, 0); al_set_target_bitmap(screen); /* Draw it enlarged. */ x = 80; y = 40; al_draw_scaled_bitmap(ex.zoom, 0, 0, w, h, x, y, w * 16, h * 16, 0); /* Draw outlines. */ for (i = 0; i < rects_num; i++) { primitive( x + rects[i * 4 + 0] * 16, y + rects[i * 4 + 1] * 16, x + rects[i * 4 + 2] * 16, y + rects[i * 4 + 3] * 16, ex.outline, true); } set_xy(8, 640 - 48); print("Thickness: %d (press T to change)", ex.thickness); print("Drawing with: %s (press S to change)", ex.software ? "software" : "hardware"); print("Supersampling: %dx (edit ex_draw.ini to change)", ex.samples); // FIXME: doesn't work // al_get_display_option(ALLEGRO_SAMPLE_BUFFERS)); }
static int allua_Bitmap_set_new_format(lua_State * L) { int format = luaL_checkint(L, 1); al_set_new_bitmap_format(format); return 0; }