| 602 | } |
| 603 | |
| 604 | static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) |
| 605 | { |
| 606 | if (y <= 0 || x <= 0 || data == NULL) |
| 607 | return 0; |
| 608 | else { |
| 609 | // Each component is stored separately. Allocate scratch space for full output scanline. |
| 610 | unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); |
| 611 | int i, len; |
| 612 | char buffer[128]; |
| 613 | char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; |
| 614 | s->func(s->context, header, sizeof(header)-1); |
| 615 | |
| 616 | len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); |
| 617 | s->func(s->context, buffer, len); |
| 618 | |
| 619 | for(i=0; i < y; i++) |
| 620 | stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*i*x); |
| 621 | STBIW_FREE(scratch); |
| 622 | return 1; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) |
| 627 | { |
no test coverage detected