diff options
author | Ariel Manzur <ariel@godotengine.org> | 2016-01-12 06:19:56 -0300 |
---|---|---|
committer | Ariel Manzur <ariel@godotengine.org> | 2016-01-12 06:24:47 -0300 |
commit | 761b08ec8f2702582f064ddfaf0a1c530cac2e05 (patch) | |
tree | 1ddfa10897b2faebffcbf32814d4d34ab6da1997 /drivers | |
parent | a625f7d07317ac4fac21962a99a7896ed13010c7 (diff) |
loading unaligned pbm
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnm/bitmap_loader_pnm.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/pnm/bitmap_loader_pnm.cpp b/drivers/pnm/bitmap_loader_pnm.cpp index b57533e521..c9298be26a 100644 --- a/drivers/pnm/bitmap_loader_pnm.cpp +++ b/drivers/pnm/bitmap_loader_pnm.cpp @@ -170,15 +170,12 @@ RES ResourceFormatPBM::load(const String &p_path,const String& p_original_path,E } DVector<uint8_t>::Read r=token.read(); - int bitwidth = width; - if (bitwidth % 8) - bitwidth+=8-(bitwidth%8); for(int i=0;i<height;i++) { for(int j=0;j<width;j++) { - char num = r[i*bitwidth+j]; + char num = r[i*width+j]; bm->set_bit(Point2i(j,i),num=='0'); } @@ -197,11 +194,14 @@ RES ResourceFormatPBM::load(const String &p_path,const String& p_original_path,E } DVector<uint8_t>::Read r=token.read(); + int bitwidth = width; + if (bitwidth % 8) + bitwidth+=8-(bitwidth%8); for(int i=0;i<height;i++) { for(int j=0;j<width;j++) { - int ofs = width*i+j; + int ofs = bitwidth*i+j; uint8_t byte = r[ofs/8]; bool bit = (byte>>(7-(ofs%8)))&1; |