Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/texture.c:
for (x = 0; x < desc.Width; x++) {
BYTE *dst = data + y * lock_rect.Pitch + x * format->bytes_per_pixel;
struct d3dx_color color;
coord.x = (x + 0.5f) / desc.Width; function(&value, &coord, &size, funcdata);
fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value);
set_d3dx_color(&color, (const struct vec4 *)&value, RANGE_FULL);
format_from_d3dx_color(format, (const struct d3dx_color *)&color, dst);
I'm pretty sure that cast isn't necessary.