🎉 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.

Started by
6 comments, last by Drevay 19 years, 11 months ago
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.
#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();
Thanks in advance. [smile]
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
Advertisement
how wide is the screen?
maybe you are blitting off screen?

Beginner in Game Development?  Read here. And read here.

 

More important would be how big is tuxx.bmp?

Jesus saves ... the rest of you take 2d4 fire damage.

Quote: Original post by 23yrold3yrold
More important would be how big is tuxx.bmp?

128x152

Of course the resolution is set to 800x600.
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
Quote: Original post by Drevay
Quote: 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.

Jesus saves ... the rest of you take 2d4 fire damage.

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.
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
Welp, looks like a 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]
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
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):
#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]
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.

This topic is closed to new replies.

Advertisement