d3dx10: Factor out image format conversion function.