Logo Search packages:      
Sourcecode: acidbase version File versions  Download package

Cpdf::o_image ( id,
action,
options = '' 
)

an image object, will be an XObject in the document, includes description and data

Definition at line 940 of file class.pdf.php.

References $options, ARC4(), encryptInit(), o_contents(), o_pages(), and o_procset().

Referenced by addJpegImage_common(), and addPngFromFile().

                                         {
  if ($action!='new'){
    $o =& $this->objects[$id];
  }
  switch($action){
    case 'new':
      // make the new object
      $this->objects[$id]=array('t'=>'image','data'=>$options['data'],'info'=>array());
      $this->objects[$id]['info']['Type']='/XObject';
      $this->objects[$id]['info']['Subtype']='/Image';
      $this->objects[$id]['info']['Width']=$options['iw'];
      $this->objects[$id]['info']['Height']=$options['ih'];
      if (!isset($options['type']) || $options['type']=='jpg'){
        if (!isset($options['channels'])){
          $options['channels']=3;
        }
        switch($options['channels']){
          case 1:
            $this->objects[$id]['info']['ColorSpace']='/DeviceGray';
            break;
          default:
            $this->objects[$id]['info']['ColorSpace']='/DeviceRGB';
            break;
        }
        $this->objects[$id]['info']['Filter']='/DCTDecode';
        $this->objects[$id]['info']['BitsPerComponent']=8;
      } else if ($options['type']=='png'){
        $this->objects[$id]['info']['Filter']='/FlateDecode';
        $this->objects[$id]['info']['DecodeParms']='<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>';
        if (strlen($options['pdata'])){
          $tmp = ' [ /Indexed /DeviceRGB '.(strlen($options['pdata'])/3-1).' ';
          $this->numObj++;
          $this->o_contents($this->numObj,'new');
          $this->objects[$this->numObj]['c']=$options['pdata'];
          $tmp.=$this->numObj.' 0 R';
          $tmp .=' ]';
          $this->objects[$id]['info']['ColorSpace'] = $tmp;
          if (isset($options['transparency'])){
            switch($options['transparency']['type']){
              case 'indexed':
                $tmp=' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
                $this->objects[$id]['info']['Mask'] = $tmp;
                break;
            }
          }
        } else {
          $this->objects[$id]['info']['ColorSpace']='/'.$options['color'];
        }
        $this->objects[$id]['info']['BitsPerComponent']=$options['bitsPerComponent'];
      }
      // assign it a place in the named resource dictionary as an external object, according to
      // the label passed in with it.
      $this->o_pages($this->currentNode,'xObject',array('label'=>$options['label'],'objNum'=>$id));
      // also make sure that we have the right procset object for it.
      $this->o_procset($this->procsetObjectId,'add','ImageC');
      break;
    case 'out':
      $tmp=$o['data'];
      $res= "\n".$id." 0 obj\n<<";
      foreach($o['info'] as $k=>$v){
        $res.="\n/".$k.' '.$v;
      }
      if ($this->encrypted){
        $this->encryptInit($id);
        $tmp = $this->ARC4($tmp);
      }
      $res.="\n/Length ".strlen($tmp)." >>\nstream\n".$tmp."\nendstream\nendobj\n";
      return $res;
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index