Encodes and writes pixel data
347573
function writePixels() {
    var myencoder = new LZWEncoder(width, height, indexedPixels, colorDepth);
    myencoder.encode(out);
  }
37829
function getPixelValues (pixelData) {
  let minPixelValue = Number.MAX_VALUE;
  let maxPixelValue = Number.MIN_VALUE;
  const len = pixelData.length;
  let pixel;

  for (let i = 0; i < len; i++) {
    pixel = pixelData[i];
    minPixelValue = minPixelValue < pixel ? minPixelValue : pixel;
    maxPixelValue = maxPixelValue > pixel ? maxPixelValue : pixel;
  }

  return {
    minPixelValue,
    maxPixelValue
  };
}
394611
private void renderData() {
		QrCodeMaskPattern mask = qr.mask;
		int count = 0;

		int length = bitLocations.size() - bitLocations.size()%8;
		while( count < length ) {
			int bits = qr.rawbits[count/8]&0xFF;

			int N = Math.min(8,bitLocations.size()-count);

			for (int i = 0; i < N; i++) {
				Point2D_I32 coor = bitLocations.get(count+i);
				int value = mask.apply(coor.y,coor.x, ((bits >> i ) & 0x01));
//				int value = ((bits >> i ) & 0x01);
				if( value > 0 ) {
					square(coor.y,coor.x);
				}
			}
			count += 8;
		}

	}
72906
def _write(self, data):
        
        frame = APIFrame(data, self._escaped).output()
        self.serial.write(frame)
353509
protected void outputToImage( double x , double y , Point2D_F64 pt ) {
		pt.x = x*scale + tranX;
		pt.y = y*scale + tranY;
	}
736041
function createPng(pixelData) {
	const length = pixelData.length + 4 - (pixelData.length % 4);
	const pixels = Math.ceil(length / 4);
	const width = Math.min(pixels, MAX_WIDTH);
	const height = Math.ceil(pixels / MAX_WIDTH);
	const bytesPerRow = width * 4;
	const buffer$$1 = buffer.Buffer.alloc((bytesPerRow + 1) * height);

	// Write pixel data to buffer
	for (let y = 0; y < height; y += 1) {
		const offset = y * bytesPerRow;
		const rowData = pixelData.slice(offset, offset + bytesPerRow);
		const rowStartX = offset + y + 1;
		const rowEndX = rowStartX + bytesPerRow;

		buffer$$1.writeUInt8(0, offset + y);
		buffer$$1.fill(rowData, rowStartX, rowEndX);
	}

	return new Promise((resolve, reject) => {
		zlib.deflate(buffer$$1, (error, deflated) => {
			if (error) {
				reject(error);
				return;
			}

			resolve(buffer.Buffer.concat([
				PNG_HEADER,
				createIHDRChunk(width, height),
				createIDATChunk(deflated),
				createIENDChunk(),
			]));
		});
	});
}
154135
public static void readPixels(DataInput in, float[] data, int numpixels) throws IOException {
        byte[] rgbe = new byte[4];
        float[] rgb = new float[3];
        int offset = 0;

        while (numpixels-- > 0) {
            in.readFully(rgbe);

            rgbe2float(rgb, rgbe, 0);

            data[offset++] = rgb[0];
            data[offset++] = rgb[1];
            data[offset++] = rgb[2];
        }
    }
1064940
private int writePlaintextData(final ByteBuffer src, int len) {
        final int pos = src.position();
        final int limit = src.limit();
        final int sslWrote;

        if (src.isDirect()) {
            sslWrote = SSL.writeToSSL(ssl, bufferAddress(src) + pos, len);
            if (sslWrote > 0) {
                src.position(pos + sslWrote);
            }
        } else {
            ByteBuf buf = alloc.directBuffer(len);
            try {
                src.limit(pos + len);

                buf.setBytes(0, src);
                src.limit(limit);

                sslWrote = SSL.writeToSSL(ssl, memoryAddress(buf), len);
                if (sslWrote > 0) {
                    src.position(pos + sslWrote);
                } else {
                    src.position(pos);
                }
            } finally {
                buf.release();
            }
        }
        return sslWrote;
    }
609514
function writeOptimizedImages(imageData) {
  return Promise.all(
    imageData.map(item =>
      pify(fs.writeFile)(item.path, item.data).then(() => item.path)
    )
  );
}
410350
def _write_data(data, fp):
    """"""
    fp.write("@data\n")

    def to_str(x):
        if pandas.isnull(x):
            return '?'
        else:
            return str(x)

    data = data.applymap(to_str)
    n_rows = data.shape[0]
    for i in range(n_rows):
        str_values = list(data.iloc[i, :].apply(_check_str_array))
        line = ",".join(str_values)
        fp.write(line)
        fp.write("\n")
809423
def encode_hdr(self, boundary):
        """"""
        boundary = encode_and_quote(boundary)

        headers = ["--%s" % boundary]

        if self.filename:
            disposition = 'form-data; name="%s"; filename="%s"' % (self.name,
                                                                   self.filename)
        else:
            disposition = 'form-data; name="%s"' % self.name

        headers.append("Content-Disposition: %s" % disposition)

        if self.filetype:
            filetype = self.filetype
        else:
            filetype = "text/plain; charset=utf-8"

        headers.append("Content-Type: %s" % filetype)

        headers.append("")
        headers.append("")

        return "\r\n".join(headers)
368706
def convert_ppm_and_pgm(self, ppmfile, pgmfile, outfile):
        
        pixels = array('B')
        pixels.fromfile(ppmfile,
                        (self.bitdepth/8) * self.color_planes *
                        self.width * self.height)
        apixels = array('B')
        apixels.fromfile(pgmfile,
                         (self.bitdepth/8) *
                         self.width * self.height)
        pixels = interleave_planes(pixels, apixels,
                                   (self.bitdepth/8) * self.color_planes,
                                   (self.bitdepth/8))
        if self.interlace:
            self.write_passes(outfile, self.array_scanlines_interlace(pixels))
        else:
            self.write_passes(outfile, self.array_scanlines(pixels))
370406
def writeTuple(self, val, what):
        
        # Limit to three values. so RGBA data drops the alpha channel
        # Format can handle up to 3 texcords
        val = val[:3]
        # Make string
        val = ' '.join([str(v) for v in val])
        # Write line
        self.writeLine('%s %s' % (what, val))
1271569
function(width, height) {

    var _width = width;
    var _height = height;
    var _data = new Array(width * height);

    var _this = {};

    _this.setPixel = function(x, y, pixel) {
	_data[y * _width + x] = pixel;
    };

    _this.write = function(out) {

	//---------------------------------
	// GIF Signature

	out.writeString('GIF87a');

	//---------------------------------
	// Screen Descriptor

	out.writeShort(_width);
	out.writeShort(_height);

	out.writeByte(0x80); // 2bit
	out.writeByte(0);
	out.writeByte(0);

	//---------------------------------
	// Global Color Map

	// black
	out.writeByte(0x00);
	out.writeByte(0x00);
	out.writeByte(0x00);

	// white
	out.writeByte(0xff);
	out.writeByte(0xff);
	out.writeByte(0xff);

	//---------------------------------
	// Image Descriptor

	out.writeString(',');
	out.writeShort(0);
	out.writeShort(0);
	out.writeShort(_width);
	out.writeShort(_height);
	out.writeByte(0);

	//---------------------------------
	// Local Color Map

	//---------------------------------
	// Raster Data

	var lzwMinCodeSize = 2;
	var raster = getLZWRaster(lzwMinCodeSize);

	out.writeByte(lzwMinCodeSize);

	var offset = 0;

	while (raster.length - offset > 255) {
	    out.writeByte(255);
	    out.writeBytes(raster, offset, 255);
	    offset += 255;
	}

	out.writeByte(raster.length - offset);
	out.writeBytes(raster, offset, raster.length - offset);
	out.writeByte(0x00);

	//---------------------------------
	// GIF Terminator
	out.writeString(';');
    };

    var bitOutputStream = function(out) {

	var _out = out;
	var _bitLength = 0;
	var _bitBuffer = 0;

	var _this = {};

	_this.write = function(data, length) {

	    if ( (data >>> length) != 0) {
		throw new Error('length over');
	    }

	    while (_bitLength + length >= 8) {
		_out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );
		length -= (8 - _bitLength);
		data >>>= (8 - _bitLength);
		_bitBuffer = 0;
		_bitLength = 0;
	    }

	    _bitBuffer = (data << _bitLength) | _bitBuffer;
	    _bitLength = _bitLength + length;
	};

	_this.flush = function() {
	    if (_bitLength > 0) {
		_out.writeByte(_bitBuffer);
	    }
	};

	return _this;
    };

    var getLZWRaster = function(lzwMinCodeSize) {

	var clearCode = 1 << lzwMinCodeSize;
	var endCode = (1 << lzwMinCodeSize) + 1;
	var bitLength = lzwMinCodeSize + 1;

	// Setup LZWTable
	var table = lzwTable();

	for (var i = 0; i < clearCode; i += 1) {
	    table.add(String.fromCharCode(i) );
	}
	table.add(String.fromCharCode(clearCode) );
	table.add(String.fromCharCode(endCode) );

	var byteOut = byteArrayOutputStream();
	var bitOut = bitOutputStream(byteOut);

	// clear code
	bitOut.write(clearCode, bitLength);

	var dataIndex = 0;

	var s = String.fromCharCode(_data[dataIndex]);
	dataIndex += 1;

	while (dataIndex < _data.length) {

	    var c = String.fromCharCode(_data[dataIndex]);
	    dataIndex += 1;

	    if (table.contains(s + c) ) {

		s = s + c;

	    } else {

		bitOut.write(table.indexOf(s), bitLength);

		if (table.size() < 0xfff) {

		    if (table.size() == (1 << bitLength) ) {
			bitLength += 1;
		    }

		    table.add(s + c);
		}

		s = c;
	    }
	}

	bitOut.write(table.indexOf(s), bitLength);

	// end code
	bitOut.write(endCode, bitLength);

	bitOut.flush();

	return byteOut.toByteArray();
    };

    var lzwTable = function() {

	var _map = {};
	var _size = 0;

	var _this = {};

	_this.add = function(key) {
	    if (_this.contains(key) ) {
		throw new Error('dup key:' + key);
	    }
	    _map[key] = _size;
	    _size += 1;
	};

	_this.size = function() {
	    return _size;
	};

	_this.indexOf = function(key) {
	    return _map[key];
	};

	_this.contains = function(key) {
	    return typeof _map[key] != 'undefined';
	};

	return _this;
    };

    return _this;
}
538077
def write_image_to_disk(self, msg, result, fh):
        """"""
        fh.write(base64.b64decode(result.group(1).encode('utf-8')))
1110572
def write_array(self, outfile, pixels):
        

        if self.interlace:
            if type(pixels) != array:
                # Coerce to array type
                fmt = 'BH'[self.bitdepth > 8]
                pixels = array(fmt, pixels)
            self.write_passes(outfile, self.array_scanlines_interlace(pixels))
        else:
            self.write_passes(outfile, self.array_scanlines(pixels))
693120
def write_ImageMapLine(tlx, tly, brx, bry, w, h, dpi, chr, segment_start, segment_end):
    
    tlx, brx = [canvas2px(x, w, dpi) for x in (tlx, brx)]
    tly, bry = [canvas2px(y, h, dpi) for y in (tly, bry)]
    chr, bac_list = chr.split(':')
    return '<area shape="rect" coords="' + \
           ",".join(str(x) for x in (tlx, tly, brx, bry)) \
           + '" href="#' + chr + '"' \
           + ' title="' + chr + ':' + str(segment_start) + '..' + str(segment_end) + '"' \
           + ' />'