BMPLoader module quick fix

Posted on
  • Hi,

    While using the BMPLoader module to quickly get some data out to a display without having to port my Python graphics library across, I found it was giving me an error: w is not defined etc...

    The only reference to 'w' in BMPLoader is in the line of code below

        img.buffer.set(new Uint8Array(bmp, addr+istride*(img.height-(y+1)), w), ostride*y);
    

    changing it to

        img.buffer.set(new Uint8Array(bmp, addr+istride*(img.height-(y+1)), this.width), ostride*y);
    

    fixes the problem. I just copied the module code into my program and converted it to a standard function then made the changes above but it would be handy if the module could be updated.

  • Awesome, thanks! I just fixed it - next time I update the website it'll start working again.

    Looking at it, I think w should be ostride. Without it, it'll work, but the array will be the full length (rather than the length of a line) so it'll be doing loads of copying and will be a lot slower than it should be :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

BMPLoader module quick fix

Posted by Avatar for Lucie @Lucie

Actions