<s>
PackBits	B-Algorithm
is	O
a	O
fast	O
,	O
simple	O
lossless	B-Algorithm
compression	I-Algorithm
scheme	O
for	O
run-length	B-Algorithm
encoding	I-Algorithm
of	O
data	O
.	O
</s>
<s>
Apple	O
introduced	O
the	O
PackBits	B-Algorithm
format	O
with	O
the	O
release	O
of	O
MacPaint	B-Operating_System
on	O
the	O
Macintosh	B-Device
computer	I-Device
.	O
</s>
<s>
TGA	O
files	O
also	O
use	O
this	O
RLE	B-Algorithm
compression	I-Algorithm
scheme	O
,	O
but	O
treats	O
data	O
stream	O
as	O
pixels	O
instead	O
of	O
bytes	O
.	O
</s>
<s>
A	O
PackBits	B-Algorithm
data	O
stream	O
consists	O
of	O
packets	O
with	O
a	O
one-byte	O
header	O
followed	O
by	O
data	O
.	O
</s>
<s>
The	O
header	O
is	O
a	O
signed	O
byte	O
;	O
the	O
data	O
can	O
be	O
signed	O
,	O
unsigned	O
,	O
or	O
packed	O
(	O
such	O
as	O
MacPaint	B-Operating_System
pixels	O
)	O
.	O
</s>
<s>
There	O
is	O
no	O
way	O
based	O
on	O
the	O
PackBits	B-Algorithm
data	O
to	O
determine	O
the	O
end	O
of	O
the	O
data	O
stream	O
;	O
that	O
is	O
to	O
say	O
,	O
one	O
must	O
already	O
know	O
the	O
size	O
of	O
the	O
compressed	O
or	O
uncompressed	O
data	O
before	O
reading	O
a	O
PackBits	B-Algorithm
data	O
stream	O
to	O
know	O
where	O
it	O
ends	O
.	O
</s>
<s>
The	O
following	O
code	O
,	O
written	O
in	O
Microsoft	B-Language
VBA	I-Language
,	O
unpacks	O
the	O
data	O
:	O
</s>
<s>
The	O
same	O
implementation	O
in	O
JavaScript	B-Language
:	O
</s>
