@Hans
bob_type *load_dt_animbrush( char *name )
{
Object *dto;
struct BitMapHeader *bm_header;
struct BitMap *dt_bitmap;
struct BitMap *new_bitmap;
struct RastPort RP;
int lock;
struct RenderInfo rinf;
char *byte;
char tmp;
short stmp;
short r;
short g;
short b;
char *alfa;
ULONG num_images,num;
ULONG num_colors;
ULONG anim_dept;
ULONG *color_regs;
unsigned char *plain;
int p,color;
int format,dept;
int pixel_size;
int rgb_color;
bob_type *new_bob = NULL;
bob_type *last_bob = NULL;
bob_type *ret = NULL;
type_bit *bob_func = NULL;
int x,y,xoff,yoff;
printf( "load datatype image %s\n",name);
if(dto = (void *) NewDTObject( name, DTA_GroupID, GID_ANIMATION, TAG_DONE))
{
SetDTAttrs ( (void *) dto, NULL,NULL, PDTA_DestMode, (ULONG) PMODE_V43,TAG_DONE);
GetDTAttrs ( (void *) dto,
ADTA_Frames, &num_images,
ADTA_NumColors, &num_colors,
ADTA_CRegs, &color_regs,
ADTA_Depth, &anim_dept,
TAG_DONE);
printf("Num images %d\n",num_images);
printf("Num colours %d\n",num_colors);
printf("Num anim depth %d\n",anim_dept);
for (color = 0; color<num_colors;color++)
{
printf ("%d %x,%x,%x\n",color, color_regs[color*3+0]>>24,color_regs[color*3+1]>>24,color_regs[color*3+2]>>24 );
}
if (num_images<1)
{
printf("Not an animation?\n");
num_images = 1;
}
for (num=0;num<num_images;num++)
{
printf("num %d\n",num);
DoDTMethod ( (void *) dto,NULL,NULL,ADTM_LOCATE,num,TRUE);
GetDTAttrs ( (void *) dto,PDTA_BitMapHeader, (ULONG *) &bm_header, ADTA_KeyFrame, (ULONG) &dt_bitmap,TAG_DONE);
// find bit format in dto.
pixel_size = p96GetBitMapAttr(__screen_bitmap,P96BMA_BYTESPERPIXEL);
printf("screens pixel size %d\n",pixel_size);
if (!bm_header)
{
printf("no bm header\n");
break;
}
if (new_bob = (void *) malloc(sizeof(bob_type)))
{
make_bitmap_alfa(new_bob, bm_header -> bmh_Width, bm_header -> bmh_Height, pixel_size);
if (ret == 0) ret = new_bob; // set return value
printf( "datatype bitmap 0x%x\n", dt_bitmap);
printf( "bob bitmap 0x%x\n", new_bob -> bitmap);
DoDTMethod ( (void *) dto,NULL,NULL,ADTM_LOADFRAME);
bob_func = new_bob -> geo.c;
bob_func -> lock(new_bob);
printf( "bob bitmap mem 0x%x\n", new_bob -> memory);
for(y=0;y<new_bob -> geo.h;y++)
{
for (x=0;x<new_bob -> geo.w;x++)
{
color = 0;
for (p=0;p<anim_dept;p++)
{
plain = (unsigned char *) (((ULONG) dt_bitmap -> Planes[p]) + ( dt_bitmap -> BytesPerRow * y));
color += plain[ x >> 8 ] & (x & 255) ? (1<<p) : 0 ;
}
rgb_color = bob_func-> color(new_bob,color_regs[color*3+0]>>24,color_regs[color*3+1]>>24,color_regs[color*3+2]>>24 );
printf("%d,%d\n",x,y);
bob_func-> pixel(new_bob, rgb_color ,x,y);
}
}
bob_func -> unlock(new_bob);
DoDTMethod ( (void *) dto,NULL,NULL,ADTM_UNLOADFRAME);
if (last_bob) { last_bob -> next = new_bob; }
last_bob = new_bob;
}
}
DisposeDTObject(dto);
}
else
{
printf("%s is loaded as image, not a animbrush!\n");
ret = load_dt_image( name );
}
return ret;
}