summaryrefslogtreecommitdiff
path: root/drivers/pnm/bitmap_loader_pnm.cpp
diff options
context:
space:
mode:
authorAriel Manzur <ariel@godotengine.org>2016-01-12 06:19:56 -0300
committerAriel Manzur <ariel@godotengine.org>2016-01-12 06:24:47 -0300
commit761b08ec8f2702582f064ddfaf0a1c530cac2e05 (patch)
tree1ddfa10897b2faebffcbf32814d4d34ab6da1997 /drivers/pnm/bitmap_loader_pnm.cpp
parenta625f7d07317ac4fac21962a99a7896ed13010c7 (diff)
loading unaligned pbm
Diffstat (limited to 'drivers/pnm/bitmap_loader_pnm.cpp')
-rw-r--r--drivers/pnm/bitmap_loader_pnm.cpp10
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;