GithubHelp home page GithubHelp logo

use on "unusual" CPU's about pixmap565 HOT 2 CLOSED

plerros avatar plerros commented on July 22, 2024
use on "unusual" CPU's

from pixmap565.

Comments (2)

plerros avatar plerros commented on July 22, 2024

The BMP format is defined using bytes.
It has words and dwords that are 2 and 4 bytes respectively.

Unsigned short is bigger or equal to 2 bytes.
I am not using uint16_t for words, because it may be smaller than 2 bytes.

Unsigned long is bigger or equal to 4 bytes.
I am not using uint32_t for dwords, because it may be smaller than 4 bytes.

The code will probably work on almost all 32-bit and 64-bit systems. (I don't have 8 or 16 bit CPUs to test it on.)

from pixmap565.

plerros avatar plerros commented on July 22, 2024

On the "unusual" CPUs matter.
I am not referring to how many bits the cpu is.
I am referring to the size of the byte, the smallest addressable memory.

From wikipedia:
The pixel array is a block of 32-bit DWORDs.

This statement is problematic, because you could have 36-bit bytes.
In such a case, a DWORD would be 144-bits (36 * 4).

A non 8-bit byte causes many issues, like:

  1. What happens to a file, if you copy it from an 8-bit byte computer to a 36-bit byte computer?
  • If the number of bytes stay the same:
    byte pixel_array_offset + 0:
    [XXXX XXXXXXXX XXXXXXXX XXXXXXXX GGGBBBBB]
    byte pixel_array_offset + 1:
    [XXXX XXXXXXXX XXXXXXXX XXXXXXXX RRRRRGGG]

    But the code would write out:
    byte pixel_array_offset + 0:
    [XXXX XXXXXXXX XXXXXXXX RRRRRGGG GGGBBBBB]

    So, no buneno.

  • If the number of bytes change:
    The whole file would be broken.
    The fields filesize, DIB_size and pixel_array_offset rely on bytes.

  1. How would you write 16 bits (a pixel), if the smallest addressable memory is 36 bits?
  • You could pack multiple pixels in a byte and then write it out, but 36 isn't divisible by 16, and you'd have to carry over the remaining bits

from pixmap565.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.