当前位置: 首页>>代码示例>>PHP>>正文


PHP Pel::maybeThrow方法代码示例

本文整理汇总了PHP中Pel::maybeThrow方法的典型用法代码示例。如果您正苦于以下问题:PHP Pel::maybeThrow方法的具体用法?PHP Pel::maybeThrow怎么用?PHP Pel::maybeThrow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pel的用法示例。


在下文中一共展示了Pel::maybeThrow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateNumber

 /**
  * Validate a number.
  *
  * This method will check that the number given is within the range
  * given my {@link getMin()} and {@link getMax()}, inclusive.  If
  * not, then a {@link PelOverflowException} is thrown.
  *
  * @param int|array the number in question.
  *
  * @return void nothing, but will throw a {@link
  * PelOverflowException} if the number is found to be outside the
  * legal range and {@link Pel::$strict} is true.
  */
 function validateNumber($n)
 {
     if ($this->dimension == 1) {
         if ($n < $this->min || $n > $this->max) {
             Pel::maybeThrow(new PelOverflowException($n, $this->min, $this->max));
         }
     } else {
         for ($i = 0; $i < $this->dimension; $i++) {
             if ($n[$i] < $this->min || $n[$i] > $this->max) {
                 Pel::maybeThrow(new PelOverflowException($n[$i], $this->min, $this->max));
             }
         }
     }
 }
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:27,代码来源:PelEntryNumber.php

示例2: setThumbnail

 /**
  * Set thumbnail data.
  *
  * Use this to embed an arbitrary JPEG image within this IFD. The
  * data will be checked to ensure that it has a proper {@link
  * PelJpegMarker::EOI} at the end.  If not, then the length is
  * adjusted until one if found.  An {@link PelIfdException} might be
  * thrown (depending on {@link Pel::$strict}) this case.
  *
  * @param PelDataWindow the thumbnail data.
  */
 function setThumbnail(PelDataWindow $d)
 {
     $size = $d->getSize();
     /* Now move backwards until we find the EOI JPEG marker. */
     while ($d->getByte($size - 2) != 0xff || $d->getByte($size - 1) != PelJpegMarker::EOI) {
         $size--;
     }
     if ($size != $d->getSize()) {
         Pel::maybeThrow(new PelIfdException('Decrementing thumbnail size ' . 'to %d bytes', $size));
     }
     $this->thumb_data = $d->getClone(0, $size);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:23,代码来源:PelIfd.php

示例3: load

 /**
  * Load data into a JPEG object.
  *
  * The data supplied will be parsed and turned into an object
  * structure representing the image.  This structure can then be
  * manipulated and later turned back into an string of bytes.
  *
  * This methods can be called at any time after a JPEG object has
  * been constructed, also after the {@link appendSection()} has been
  * called to append custom sections.  Loading several JPEG images
  * into one object will accumulate the sections, but there will only
  * be one {@link PelJpegMarker::SOS} section at any given time.
  *
  * @param PelDataWindow the data that will be turned into JPEG
  * sections.
  */
 function load(PelDataWindow $d)
 {
     Pel::debug('Parsing %d bytes...', $d->getSize());
     /* JPEG data is stored in big-endian format. */
     $d->setByteOrder(PelConvert::BIG_ENDIAN);
     /* Run through the data to read the sections in the image.  After
      * each section is read, the start of the data window will be
      * moved forward, and after the last section we'll terminate with
      * no data left in the window. */
     while ($d->getSize() > 0) {
         /* JPEG sections start with 0xFF. The first byte that is not
          * 0xFF is a marker (hopefully).
          */
         for ($i = 0; $i < 7; $i++) {
             if ($d->getByte($i) != 0xff) {
                 break;
             }
         }
         $marker = $d->getByte($i);
         if (!PelJpegMarker::isValid($marker)) {
             throw new PelJpegInvalidMarkerException($marker, $i);
         }
         /* Move window so first byte becomes first byte in this
          * section. */
         $d->setWindowStart($i + 1);
         if ($marker == PelJpegMarker::SOI || $marker == PelJpegMarker::EOI) {
             $content = new PelJpegContent(new PelDataWindow());
             $this->appendSection($marker, $content);
         } else {
             /* Read the length of the section.  The length includes the
              * two bytes used to store the length. */
             $len = $d->getShort(0) - 2;
             Pel::debug('Found %s section of length %d', PelJpegMarker::getName($marker), $len);
             /* Skip past the length. */
             $d->setWindowStart(2);
             if ($marker == PelJpegMarker::APP1) {
                 try {
                     $content = new PelExif();
                     $content->load($d->getClone(0, $len));
                 } catch (PelInvalidDataException $e) {
                     /* We store the data as normal JPEG content if it could
                      * not be parsed as Exif data. */
                     $content = new PelJpegContent($d->getClone(0, $len));
                 }
                 $this->appendSection($marker, $content);
                 /* Skip past the data. */
                 $d->setWindowStart($len);
             } elseif ($marker == PelJpegMarker::COM) {
                 $content = new PelJpegComment();
                 $content->load($d->getClone(0, $len));
                 $this->appendSection($marker, $content);
                 $d->setWindowStart($len);
             } else {
                 $content = new PelJpegContent($d->getClone(0, $len));
                 $this->appendSection($marker, $content);
                 /* Skip past the data. */
                 $d->setWindowStart($len);
                 /* In case of SOS, image data will follow. */
                 if ($marker == PelJpegMarker::SOS) {
                     /* Some images have some trailing (garbage?) following the
                      * EOI marker.  To handle this we seek backwards until we
                      * find the EOI marker.  Any trailing content is stored as
                      * a PelJpegContent object. */
                     $length = $d->getSize();
                     while ($d->getByte($length - 2) != 0xff || $d->getByte($length - 1) != PelJpegMarker::EOI) {
                         $length--;
                     }
                     $this->jpeg_data = $d->getClone(0, $length - 2);
                     Pel::debug('JPEG data: ' . $this->jpeg_data->__toString());
                     /* Append the EOI. */
                     $this->appendSection(PelJpegMarker::EOI, new PelJpegContent(new PelDataWindow()));
                     /* Now check to see if there are any trailing data. */
                     if ($length != $d->getSize()) {
                         Pel::maybeThrow(new PelException('Found trailing content ' . 'after EOI: %d bytes', $d->getSize() - $length));
                         $content = new PelJpegContent($d->getClone($length));
                         /* We don't have a proper JPEG marker for trailing
                          * garbage, so we just use 0x00... */
                         $this->appendSection(0x0, $content);
                     }
                     /* Done with the loop. */
                     break;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:sansandeep143,项目名称:av,代码行数:101,代码来源:PelJpeg.php


注:本文中的Pel::maybeThrow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。