| 1856 | |
| 1857 | #ifndef STBI_NO_LINEAR |
| 1858 | static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) |
| 1859 | { |
| 1860 | int i,k,n; |
| 1861 | float *output; |
| 1862 | if (!data) return NULL; |
| 1863 | output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); |
| 1864 | if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } |
| 1865 | // compute number of non-alpha components |
| 1866 | if (comp & 1) n = comp; else n = comp-1; |
| 1867 | for (i=0; i < x*y; ++i) { |
| 1868 | for (k=0; k < n; ++k) { |
| 1869 | output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); |
| 1870 | } |
| 1871 | } |
| 1872 | if (n < comp) { |
| 1873 | for (i=0; i < x*y; ++i) { |
| 1874 | output[i*comp + n] = data[i*comp + n]/255.0f; |
| 1875 | } |
| 1876 | } |
| 1877 | STBI_FREE(data); |
| 1878 | return output; |
| 1879 | } |
| 1880 | #endif |
| 1881 | |
| 1882 | #ifndef STBI_NO_HDR |
no test coverage detected