Esempio n. 1
0
 /**
  * Construct a new data window with the data supplied.
  *
  * @param
  *            mixed the data that this window will contain. This can
  *            either be given as a string (interpreted litteraly as a sequence
  *            of bytes) or a PHP image resource handle. The data will be copied
  *            into the new data window.
  *
  * @param
  *            boolean the initial byte order of the window. This must
  *            be either {@link PelConvert::LITTLE_ENDIAN} or {@link
  *            PelConvert::BIG_ENDIAN}. This will be used when integers are
  *            read from the data, and it can be changed later with {@link
  *            setByteOrder()}.
  */
 public function __construct($data = '', $endianess = PelConvert::LITTLE_ENDIAN)
 {
     if (is_string($data)) {
         $this->data = $data;
     } elseif (is_resource($data) && get_resource_type($data) == 'gd') {
         /*
          * The ImageJpeg() function insists on printing the bytes
          * instead of returning them in a more civil way as a string, so
          * we have to buffer the output...
          */
         ob_start();
         ImageJpeg($data, null, Pel::getJPEGQuality());
         $this->data = ob_get_clean();
     } else {
         throw new PelInvalidArgumentException('Bad type for $data: %s', gettype($data));
     }
     $this->order = $endianess;
     $this->size = strlen($this->data);
 }