7 linear_argb_to_premult_argb (float a,
15 return (uint32_t) (a * 255.0f + 0.5f) << 24
16 | (uint32_t) (r * 255.0f + 0.5f) << 16
17 | (uint32_t) (g * 255.0f + 0.5f) << 8
18 | (uint32_t) (b * 255.0f + 0.5f) << 0;
22 lin2srgb (float linear)
24 if (linear < 0.0031308f)
25 return linear * 12.92f;
27 return 1.055f * powf (linear, 1.0f/2.4f) - 0.055f;
31 linear_argb_to_premult_srgb_argb (float a,
39 return (uint32_t) (a * 255.0f + 0.5f) << 24
40 | (uint32_t) (r * 255.0f + 0.5f) << 16
41 | (uint32_t) (g * 255.0f + 0.5f) << 8
42 | (uint32_t) (b * 255.0f + 0.5f) << 0;
46 main (int argc, char **argv)
53 uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
54 uint32_t *src1 = malloc (WIDTH * HEIGHT * 4);
55 pixman_image_t *dest_img, *src1_img;
57 dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8_sRGB,
61 src1_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
66 for (y = 0; y < HEIGHT; y ++)
69 for (x = 0; x < WIDTH; x ++)
71 alpha = (float) x / WIDTH;
72 src1[p + x] = linear_argb_to_premult_argb (alpha, 1, 0, 1);
73 dest[p + x] = linear_argb_to_premult_srgb_argb (1-alpha, 0, 1, 0);
77 pixman_image_composite (PIXMAN_OP_ADD, src1_img, NULL, dest_img,
78 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
79 pixman_image_unref (src1_img);
82 show_image (dest_img);
83 pixman_image_unref (dest_img);