36 FILE *
f = g_fopen(filename,
"rb");
43 fseek(
f, 0, SEEK_END);
44 size_t filesize = ftell(
f);
45 fseek(
f, 0, SEEK_SET);
47 void *read_buffer = g_malloc(filesize);
49 if(fread(read_buffer, 1, filesize,
f) != filesize)
59 if(!WebPGetInfo(read_buffer, filesize, &w, &h))
71 img->
dsc.
bpp = 4 *
sizeof(float);
74 img->
flags &= ~DT_IMAGE_RAW;
75 img->
flags &= ~DT_IMAGE_S_RAW;
76 img->
flags &= ~DT_IMAGE_HDR;
94 uint8_t *int_RGBA_buf = WebPDecodeRGBA(read_buffer, filesize, &w, &h);
105 for(
int i=0;
i < w*h*4;
i++)
107 intval = *(int_RGBA_buf+
i);
108 floatval = intval / 255.f;
109 *(mipbuf+
i) = floatval;
112 WebPFree(int_RGBA_buf);
114 wp_data.bytes = (uint8_t *)read_buffer;
115 wp_data.size = filesize;
116 mux = WebPMuxCreate(&wp_data, 0);
120 WebPMuxGetChunk(mux,
"ICCP", &icc_profile);
124 img->
profile = (uint8_t *)g_malloc0(icc_profile.size);
125 memcpy(img->
profile, icc_profile.bytes, icc_profile.size);