Only uint8 and uint16 images are currently supported.
500247
def _validate_image_datatype(self, img_array):
        
        if img_array.dtype != np.uint8 and img_array.dtype != np.uint16:
            msg = ("Only uint8 and uint16 datatypes are currently supported "
                   "when writing.")
            raise RuntimeError(msg)
260431
function UInt8(value, opt) {
	SingleType.call(this, value, 1, Buffer.prototype.readUInt8, Buffer.prototype.writeUInt8, opt);
}
1294380
public static void binary(Image srcImage, ImageOutputStream destImageStream, String imageType) throws IORuntimeException {
		write(binary(srcImage), imageType, destImageStream);
	}
522852
def uint8_3(self, val1, val2, val3):
        """"""
        try:
            self.msg += [pack("BBB", val1, val2, val3)]
        except struct.error:
            raise ValueError("Expected uint8")
        return self
1371977
def _bnot16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2])
    output.append('call __BNOT16')
    output.append('push hl')
    REQUIRES.add('bnot16.asm')
    return output
109473
def _neg8(ins):
    
    output = _8bit_oper(ins.quad[2])
    output.append('neg')
    output.append('push af')

    return output
1019104
def quantize(image, bits_per_channel=None):

    ''''''

    if bits_per_channel is None:
        bits_per_channel = 6

    assert image.dtype == np.uint8

    shift = 8-bits_per_channel
    halfbin = (1 << shift) >> 1

    return ((image.astype(int) >> shift) << shift) + halfbin
1148230
def _neg16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2])
    output.append('call __NEGHL')
    output.append('push hl')
    REQUIRES.add('neg16.asm')
    return output
363425
def uint8(self, val):
        """"""
        try:
            self.msg += [pack("B", val)]
        except struct.error:
            raise ValueError("Expected uint32")
        return self
1072261
def is_contiguous(self):
        
        if (self.compression != 1
                or self.bitspersample not in (8, 16, 32, 64)):
            return None
        if 'TileWidth' in self.tags:
            if (self.imagewidth != self.tilewidth or
                    self.imagelength % self.tilelength or
                    self.tilewidth % 16 or self.tilelength % 16):
                return None
            if ('ImageDepth' in self.tags and 'TileDepth' in self.tags and
                    (self.imagelength != self.tilelength or
                     self.imagedepth % self.tiledepth)):
                return None

        offsets = self.dataoffsets
        bytecounts = self.databytecounts
        if len(offsets) == 1:
            return offsets[0], bytecounts[0]
        if self.is_stk or all((offsets[i] + bytecounts[i] == offsets[i+1] or
                               bytecounts[i+1] == 0)  # no data/ignore offset
                              for i in range(len(offsets)-1)):
            return offsets[0], sum(bytecounts)
        return None
1010023
def read_uint8(data: nil, stream: nil, offset: 0)
      _read_fixint(name: :uint8,    length: 1, pack_format: PACK_FORMAT_UINT8,    data: data, stream: stream, offset: offset)
    end
707531
def _lei16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2], ins.quad[3])
    output.append('call __LEI16')
    output.append('push af')
    REQUIRES.add('lei16.asm')
    return output
1016214
function getSnowflakeIdFromUint8Array(Uint8Arr) {
  // packaged lib uses base64 not base64URL, so swap the different chars
  return base64js.fromByteArray(Uint8Arr).substring(0, 11).replace(/\+/g, '-').replace(/\//g, '_');
}
1163397
function encode_8bit(data) {
    var len = data.length;
    var bits = [];

    for (var i = 0; i < len; i++) {
        pushBits(bits, 8, data[i]);
    }

    var res = {};

    var d = [0, 1, 0, 0];
    pushBits(d, 16, len);
    res.data10 = res.data27 = d.concat(bits);

    if (len < 256) {
        var d = [0, 1, 0, 0];
        pushBits(d, 8, len);
        res.data1 = d.concat(bits);
    }

    return res;
}
235634
private BufferedImage to16Bit1ComponentGrayScale(int[][] decoded, int precision, int width, int height) {
        BufferedImage image;
        if (precision == 16) {
            image = new BufferedImage(width, height, BufferedImage.TYPE_USHORT_GRAY);
        }
        else {
            ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {precision}, false, false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
            image = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(width, height), colorModel.isAlphaPremultiplied(), null);
        }

        short[] imageBuffer = ((DataBufferUShort) image.getRaster().getDataBuffer()).getData();

        for (int i = 0; i < imageBuffer.length; i++) {
            imageBuffer[i] = (short) decoded[0][i];
        }

        return image;
    }
913607
def read_uint8(self, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.unpack('%sB' % endian)
1255727
function UInt16Le(value, opt) {
	SingleType.call(this, value, 2, Buffer.prototype.readUInt16LE, Buffer.prototype.writeUInt16LE, opt);
}