Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » create_sub_bitmap

This thread is locked; no one can reply to it. rss feed Print
create_sub_bitmap
Miles Lombardi
Member #5,876
May 2005

What exactly does this do?
Does it blit part of the parent to a newly created child?
Or does it set up like a pointer within the BITMAP* and a clip x y and a width and height?
It's just for efficiency reasons you see.

Raf256
Member #3,501
May 2003

AFAIR it is closer to the second method - just faslty setup some pointers/integers (clipping) to access something insied other bitmap's data

Neil Walker
Member #210
April 2000
avatar

second point. but you still need to destroy it when finished, and of course destroy it before you destroy the master.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Ceagon Xylas
Member #5,495
February 2005
avatar

Yeah I use it in situations like when I have a sprite sheet.

BITMAP *sprite_sheet=load_pcx("blah/blah.pcx",NULL);
BITMAP *frame=create_sub_bitmap(sprite_sheet,0,0,0,0);
draw_sprite(buffer,frame,x,y);
destroy_bitmap(frame);

Or
draw_sprite(buffer,create_sub_bitmap(sprite_sheet,0,0,0,0),x,y);

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

draw_sprite(buffer,create_sub_bitmap(sprite_sheet,0,0,0,0),x,y);

Except thats a horrible memory leak.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Ceagon Xylas
Member #5,495
February 2005
avatar

Figures. My code usually winds up being terrible.
So stick to method 1? =]

Go to: