6 pixman_double_to_fixed (x)
12 convert_to_srgb (uint16_t in)
14 double d = in * (1/65535.0);
20 d = (1 + a) * pow (d, 1 / 2.4) - a;
22 return (d * 65535.0) + 0.5;
26 convert_color (pixman_color_t *dest_srgb, pixman_color_t *linear)
28 dest_srgb->alpha = convert_to_srgb (linear->alpha);
29 dest_srgb->red = convert_to_srgb (linear->red);
30 dest_srgb->green = convert_to_srgb (linear->green);
31 dest_srgb->blue = convert_to_srgb (linear->blue);
35 main (int argc, char **argv)
37 static const pixman_trapezoid_t traps[] =
40 { { F(20.0), F(10.10) },
41 { F(5.3), F(280.0) } },
42 { { F(20.3), F(10.10) },
43 { F(5.6), F(280.0) } }
46 { { F(40.0), F(10.10) },
47 { F(15.3), F(280.0) } },
48 { { F(41.0), F(10.10) },
49 { F(16.3), F(280.0) } }
52 { { F(120.0), F(10.10) },
53 { F(5.3), F(280.0) } },
54 { { F(128.3), F(10.10) },
55 { F(6.6), F(280.0) } }
58 { { F(60.0), F(10.10) },
59 { F(25.3), F(280.0) } },
60 { { F(61.0), F(10.10) },
61 { F(26.3), F(280.0) } }
64 { { F(90.0), F(10.10) },
65 { F(55.3), F(280.0) } },
66 { { F(93.0), F(10.10) },
67 { F(58.3), F(280.0) } }
69 { F(130.10), F(150.0),
70 { { F(100.0), F(130.10) },
71 { F(250.3), F(150.0) } },
72 { { F(110.0), F(130.10) },
73 { F(260.3), F(150.0) } }
75 { F(170.10), F(240.0),
76 { { F(100.0), F(170.10) },
77 { F(120.3), F(240.0) } },
78 { { F(250.0), F(170.10) },
79 { F(250.3), F(240.0) } }
83 pixman_image_t *src, *dest_srgb, *dest_linear;
84 pixman_color_t bg = { 0x0000, 0x0000, 0x0000, 0xffff };
85 pixman_color_t fg = { 0xffff, 0xffff, 0xffff, 0xffff };
86 pixman_color_t fg_srgb;
89 d = malloc (WIDTH * HEIGHT * 4);
91 dest_srgb = pixman_image_create_bits (
92 PIXMAN_a8r8g8b8_sRGB, WIDTH, HEIGHT, d, WIDTH * 4);
93 dest_linear = pixman_image_create_bits (
94 PIXMAN_a8r8g8b8, WIDTH, HEIGHT, d, WIDTH * 4);
96 src = pixman_image_create_solid_fill (&bg);
97 pixman_image_composite32 (PIXMAN_OP_SRC,
99 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
101 src = pixman_image_create_solid_fill (&fg);
103 pixman_composite_trapezoids (PIXMAN_OP_OVER,
104 src, dest_srgb, PIXMAN_a8,
105 0, 0, 10, 10, G_N_ELEMENTS (traps), traps);
107 convert_color (&fg_srgb, &fg);
108 src = pixman_image_create_solid_fill (&fg_srgb);
110 pixman_composite_trapezoids (PIXMAN_OP_OVER,
111 src, dest_linear, PIXMAN_a8,
112 0, 0, 310, 10, G_N_ELEMENTS (traps), traps);
114 show_image (dest_linear);
115 pixman_image_unref(dest_linear);