create_sub_bitmap
Miles Lombardi

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

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

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

Ceagon Xylas

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
Quote:

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

Except thats a horrible memory leak.

Ceagon Xylas

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

Thread #561937. Printed from Allegro.cc