Skip to content

Instantly share code, notes, and snippets.

@BorisTheBrave
Created January 3, 2014 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BorisTheBrave/8246878 to your computer and use it in GitHub Desktop.
Save BorisTheBrave/8246878 to your computer and use it in GitHub Desktop.
diff --git a/CImg.h b/CImg.h
index ff082ae..28ee9b6 100644
--- a/CImg.h
+++ b/CImg.h
@@ -35808,7 +35808,8 @@ namespace cimg_library_suffixed {
int
file_size = header[0x02] + (header[0x03]<<8) + (header[0x04]<<16) + (header[0x05]<<24),
offset = header[0x0A] + (header[0x0B]<<8) + (header[0x0C]<<16) + (header[0x0D]<<24),
- dx = header[0x12] + (header[0x13]<<8) + (header[0x14]<<16) + (header[0x15]<<24),
+ header_size = header[0x0E] + (header[0x0F] << 8) + (header[0x10] << 16) + (header[0x11] << 24),
+ dx = header[0x12] + (header[0x13] << 8) + (header[0x14] << 16) + (header[0x15] << 24),
dy = header[0x16] + (header[0x17]<<8) + (header[0x18]<<16) + (header[0x19]<<24),
compression = header[0x1E] + (header[0x1F]<<8) + (header[0x20]<<16) + (header[0x21]<<24),
nb_colors = header[0x2E] + (header[0x2F]<<8) + (header[0x30]<<16) + (header[0x31]<<24),
@@ -35820,6 +35821,10 @@ namespace cimg_library_suffixed {
std::fseek(nfile,54,SEEK_SET);
}
+ if (header_size > 40) {
+ std::fseek(nfile, header_size - 40, SEEK_CUR);
+ }
+
const int
cimg_iobuffer = 12*1024*1024,
dx_bytes = (bpp==1)?(dx/8+(dx%8?1:0)):((bpp==4)?(dx/2+(dx%2?1:0)):(dx*bpp/8)),
@@ -35829,7 +35834,7 @@ namespace cimg_library_suffixed {
CImg<intT> colormap;
if (bpp<16) { if (!nb_colors) nb_colors = 1<<bpp; } else nb_colors = 0;
if (nb_colors) { colormap.assign(nb_colors); cimg::fread(colormap._data,nb_colors,nfile); }
- const int xoffset = offset - 54 - 4*nb_colors;
+ const int xoffset = offset - 14 - header_size - 4*nb_colors;
if (xoffset>0) std::fseek(nfile,xoffset,SEEK_CUR);
CImg<ucharT> buffer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment