#include <allegro.h>
int main(int argc, char *argv[])
{
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
BITMAP *my_pic;
my_pic = load_bitmap("tuxx.bmp", NULL);
acquire_screen();
blit(my_pic, screen, 0, 0, 0, 0, 50, 50); // draw from 0,0 to 50,50 on postion 0,0
blit(my_pic, screen, 50, 50, 722, 498, 128, 152); // draw from 50,50 to 128, 152 on position 722,498
blit(my_pic, screen, 0, 50, 0, 498, 50, 152); // draws on the bottum left
blit(my_pic, screen, 128, 0, 722, 0, 78, 102); // want to draw on the upper right
readkey();
destroy_bitmap(my_pic);
return(0);
}
END_OF_MAIN();
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Getting part of an image to blit to the upper right corner.
So I've been trying to properly blit the rest of my image to the upper right hand corner (as you can see from the code below that I've put it in the upper left, lower left, and lower right corners already).
I just can't seem to get it to blit to the upper right corner, I've been trying for quite some time.
Any help would be much appreciated.
Thanks in advance. [smile]
Quote: Original post by 23yrold3yrold
More important would be how big is tuxx.bmp?
128x152
Of course the resolution is set to 800x600.
Quote: Original post by DrevayQuote: Original post by 23yrold3yrold
More important would be how big is tuxx.bmp?
128x152
Of course the resolution is set to 800x600.
I knew it. :) Drevay, why is the third parameter to blit() 128? That's the upper-left coordinate of where you're blitting from the source bitmap. Which is its right edge. Not good. ;)
Change it to 64 (to start from the middle) or something.
Ugh, I've tried so many combinations it's not funny. 0, 152 for the 3rd and 4th params should work by your logic, 23, but I've also tried various other routes.
Argh.
EDIT - I'm not trying to split it into 4 equal peices, just to let you know.
Argh.
EDIT - I'm not trying to split it into 4 equal peices, just to let you know.
Welp, looks like a figured it out. [smile]
I just had to take the third blit and semi-reverse it.
Observe:
I feel great now that I've figured it out. [smile]
I just had to take the third blit and semi-reverse it.
Observe:
blit(my_pic, screen, 0, 50, 0, 498, 50, 152); // draws on the bottum left blit(my_pic, screen, 50, 0, 722, 0, 152, 50); // want to draw on the upper right
I feel great now that I've figured it out. [smile]
Well, I've made it split itself evenly (although it doesn't LOOK entirely even). Here's the source, and the end of this little test (unless somebody has some input):
Thanks for the help. [smile]
#include <allegro.h>int main(int argc, char *argv[]){ allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0); BITMAP *my_pic; my_pic = load_bitmap("tuxx.bmp", NULL); acquire_screen(); blit(my_pic, screen, 0, 0, 0, 0, 64, 76); // draw from 0,0 to 50,50 on postion 0,0 blit(my_pic, screen, 64, 76, 736, 524, 128, 152); // draw from 50,50 to 128, 152 on position 722,498 blit(my_pic, screen, 0, 76, 0, 524, 64, 152); // draws on the bottum left blit(my_pic, screen, 64, 0, 736, 0, 128, 76); // want to draw on the upper right readkey(); destroy_bitmap(my_pic); return(0);}END_OF_MAIN();
Thanks for the help. [smile]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement