Created
March 5, 2017 07:46
-
-
Save tfogo/4aae107ed36fc851dba29deba769640b to your computer and use it in GitHub Desktop.
Read a bitmap file with APL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:Class Bitmap | |
:Field Public FileTie | |
:Field Public BMPHeader | |
:Field Public DIPHeader | |
:Field Public ImageTable | |
:Field Public ImageWidth | |
:Field Public ImageHeight | |
:Field Public ImageDataOffset | |
:Field Public Bytes | |
∇ open path;offset;w;h;bytes;data;size;DIPHeaderSize | |
:Implements Constructor | |
:Access Public | |
FileTie←path ⎕NTIE 0 | |
BMPHeader←⎕NREAD FileTie 83 14 0 | |
DIPHeaderSize←1⊃⎕NREAD FileTie 323 1 14 | |
DIPHeader←⎕NREAD FileTie 83 DIPHeaderSize 14 | |
offset←1⊃⎕NREAD FileTie 323 1 10 | |
w←1⊃⎕NREAD FileTie 323 1 18 | |
h←1⊃⎕NREAD FileTie 323 1 22 | |
bytes←(1⊃⎕NREAD FileTie 163 1 28)÷8 | |
size←bytes×h×w | |
data←⎕NREAD FileTie 83 size offset | |
ImageWidth←w | |
ImageHeight←h | |
ImageDataOffset←offset | |
Bytes←bytes | |
ImageTable←256|bytes h w⍴⍉(h×w) bytes⍴data | |
⎕NUNTIE FileTie | |
∇ | |
:EndClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment