These are the first steps towards code sharing, finally :)
Patch 4 is a bit big, but it's just copying code from various source files into a single source file. I can attempt to split if if that's preferable for review purposes.
-- v2: d3dx10: Use shared d3dx code in get_image_info when possible. d3dx9: Move functions intended for code sharing into a separate source file. d3dx9: Introduce d3dx_image_file_format enumeration.