| | | Originally posted by slinga@Tue, 2005-12-13 @ 01:04 AM Thanks Dibz, I got allegro mostly working. I went through some basic tutorials and I got bitmaps loading. Now all I have to do is figure out how to modify bitmaps on the fly in memory and I'm done. Thanks a lot. [post=142472]Quoted post[/post] |
You can modify them using the graphics functions: putpixel, getpixel, rectfill, line, etc. For example: Code: | | | BITMAP *bmp = NULL; PALETTE pal; allegro_init(); set_color_depth(8); set_graphics_mode(GFX_VGA, 320, 200, 0, 0); // Clear palette memset(pal, 0, sizeof(pal)); // Make colors pal[0].r = pal[0].g = pal[0].b = 0x00; // Color #0 is black pal[1].r = pal[1].g = pal[1].b = 0xFF; // Color #1 is white // Assign palette to display device set_palette(pal); // Create bitmap in memory bmp = create_bitmap(320, 200); // Clear to color 0 clear_to_color(bmp, 0); // Put a white dot at (0,0) putpixel(bmp, 0, 0, 1); // Draw a white line from (10,10)-(20,20) line(bmp, 10, 10, 20, 20, 1); // Copy bitmap to display device blit(bmp, screen, 0, 0, 0, 0, 320, 200); // Save results for fun save_pcx("test.pcx", bmp, pal); |
You can also directly access the bitmap memory like this: Code: | | | void my_putpixel(BITMAP *bmp, int x, int y, int color) { bmp->line[y][x] = color; } |
Good for custom drawing routines where the overhead of a zillion putpixel() calls would affect performance. Just don't touch the 'screen' bitmap that way.  |