void um_init(um *u, long length, unsigned char *buffer) { int i; u->r[0] = 0; u->r[1] = 0; u->r[2] = 0; u->r[3] = 0; u->r[4] = 0; u->r[5] = 0; u->r[6] = 0; u->r[7] = 0; u->finger = 0; u->arrays = 1; u->a = malloc(sizeof(array)*u->arrays); u->a[0].id = 0; u->a[0].length = length; u->a[0].elt = malloc(length*sizeof(platter));//buffer; // portable endian handling thanks to http://commandcenter.blogspot.co.uk/2012/04/byte-order-fallacy.html #define LITTLE(a,b,c,d) (a<<0)|(b<<8)|(c<<16)|(d<<24) #define BIG(a,b,c,d) (a<<24)|(b<<16)|(c<<8)|(d<<0) for(i = 0; i < length; i++) { u->a[0].elt[i] = BIG(buffer[4*i+0],buffer[4*i+1],buffer[4*i+2],buffer[4*i+3]); } }
inline void ft_resalpha(t_color *c, t_color bg) { t_big delta; if (INVI(*c)) { *c = bg; return ; } delta = BIG(c->b.a) / 255; c->b.a = 255; c->b.r = ft_mix(c->b.r, bg.b.r, delta); c->b.g = ft_mix(c->b.g, bg.b.g, delta); c->b.b = ft_mix(c->b.b, bg.b.b, delta); }