function _putimage(&$info)
{
$this->_newobj();
$info['n'] = $this->n;
$this->_out('<</Type /XObject');
$this->_out('/Subtype /Image');
$this->_out('/Width ' . $info['w']);
$this->_out('/Height ' . $info['h']);
if ($info['cs'] == 'Indexed') {
$this->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
} else {
$this->_out('/ColorSpace /' . $info['cs']);
if ($info['cs'] == 'DeviceCMYK') {
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
}
}
$this->_out('/BitsPerComponent ' . $info['bpc']);
if (isset($info['f'])) {
$this->_out('/Filter /' . $info['f']);
}
if (isset($info['dp'])) {
$this->_out('/DecodeParms <<' . $info['dp'] . '>>');
}
if (isset($info['trns']) && is_array($info['trns'])) {
$trns = '';
for ($i = 0; $i < count($info['trns']); $i++) {
$trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
}
$this->_out('/Mask [' . $trns . ']');
}
if (isset($info['smask'])) {
$this->_out('/SMask ' . ($this->n + 1) . ' 0 R');
}
$this->_out('/Length ' . strlen($info['data']) . '>>');
$this->_putstream($info['data']);
$this->_out('endobj');
// Soft mask
if (isset($info['smask'])) {
$dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns ' . $info['w'];
$smask = array('w' => $info['w'], 'h' => $info['h'], 'cs' => 'DeviceGray', 'bpc' => 8, 'f' => $info['f'], 'dp' => $dp, 'data' => $info['smask']);
$this->_putimage($smask);
}
// Palette
if ($info['cs'] == 'Indexed') {
$filter = $this->compress ? '/Filter /FlateDecode ' : '';
$pal = $this->compress ? gzcompress($info['pal']) : $info['pal'];
$this->_newobj();
$this->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>');
$this->_putstream($pal);
$this->_out('endobj');
}
}