Source for file PelEntryLong.php

Documentation is available at PelEntryLong.php

  1. <?php
  2.  
  3. /*  PEL: PHP Exif Library.  A library with support for reading and
  4.  *  writing all Exif headers in JPEG and TIFF images using PHP.
  5.  *
  6.  *  Copyright (C) 2004, 2005, 2006  Martin Geisler.
  7.  *
  8.  *  This program is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2 of the License, or
  11.  *  (at your option) any later version.
  12.  *
  13.  *  This program is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with this program in the file COPYING; if not, write to the
  20.  *  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  21.  *  Boston, MA 02110-1301 USA
  22.  */
  23.  
  24. /* $Id$ */
  25.  
  26.  
  27. /**
  28.  * Classes used to hold longs, both signed and unsigned.
  29.  *
  30.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  31.  * @version $Revision$
  32.  * @date $Date$
  33.  * @license http://www.gnu.org/licenses/gpl.html GNU General Public
  34.  *  License (GPL)
  35.  * @package PEL
  36.  */
  37.  
  38. /**#@+ Required class definitions. */
  39. require_once('PelEntryNumber.php');
  40. /**#@-*/
  41.  
  42.  
  43. /**
  44.  * Class for holding unsigned longs.
  45.  *
  46.  * This class can hold longs, either just a single long or an array of
  47.  * longs.  The class will be used to manipulate any of the Exif tags
  48.  * which can have format {@link PelFormat::LONG} like in this
  49.  * example:
  50.  * <code>
  51.  * $w = $ifd->getEntry(PelTag::EXIF_IMAGE_WIDTH);
  52.  * $w->setValue($w->getValue() / 2);
  53.  * $h = $ifd->getEntry(PelTag::EXIF_IMAGE_HEIGHT);
  54.  * $h->setValue($h->getValue() / 2);
  55.  * </code>
  56.  * Here the width and height is updated to 50% of their original
  57.  * values.
  58.  *
  59.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  60.  * @package PEL
  61.  */
  62. class PelEntryLong extends PelEntryNumber {
  63.  
  64.   /**
  65.    * Make a new entry that can hold an unsigned long.
  66.    *
  67.    * The method accept its arguments in two forms: several integer
  68.    * arguments or a single array argument.  The {@link getValue}
  69.    * method will always return an array except for when a single
  70.    * integer argument is given here, or when an array with just a
  71.    * single integer is given.
  72.    *
  73.    * This means that one can conveniently use objects like this:
  74.    * <code>
  75.    * $a = new PelEntryLong(PelTag::EXIF_IMAGE_WIDTH, 123456);
  76.    * $b = $a->getValue() - 654321;
  77.    * </code>
  78.    * where the call to {@link getValue} will return an integer instead
  79.    * of an array with one integer element, which would then have to be
  80.    * extracted.
  81.    *
  82.    * @param PelTag the tag which this entry represents.  This
  83.    *  should be one of the constants defined in {@link PelTag},
  84.    *  e.g., {@link PelTag::IMAGE_WIDTH}, or any other tag which can
  85.    *  have format {@link PelFormat::LONG}.
  86.    *
  87.    * @param int $value... the long(s) that this entry will
  88.    *  represent or an array of longs.  The argument passed must obey
  89.    *  the same rules as the argument to {@link setValue}, namely that
  90.    *  it should be within range of an unsigned long (32 bit), that is
  91.    *  between 0 and 4294967295 (inclusive).  If not, then a {@link }
  92.    *  PelExifOverflowException} will be thrown.
  93.    */
  94.   function __construct($tag /* $value... */{
  95.     $this->tag    = $tag;
  96.     $this->min    = 0;
  97.     $this->max    = 4294967295;
  98.     $this->format = PelFormat::LONG;
  99.  
  100.     $value func_get_args();
  101.     array_shift($value);
  102.     $this->setValueArray($value);
  103.   }
  104.  
  105.  
  106.   /**
  107.    * Convert a number into bytes.
  108.    *
  109.    * @param int the number that should be converted.
  110.    *
  111.    * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  112.    *  {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  113.    *
  114.    * @return string bytes representing the number given.
  115.    */
  116.   function numberToBytes($number$order{
  117.     return PelConvert::longToBytes($number$order);
  118.   }
  119. }
  120.  
  121.  
  122. /**
  123.  * Class for holding signed longs.
  124.  *
  125.  * This class can hold longs, either just a single long or an array of
  126.  * longs.  The class will be used to manipulate any of the Exif tags
  127.  * which can have format {@link PelFormat::SLONG}.
  128.  *
  129.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  130.  * @package PEL
  131.  */
  132. class PelEntrySLong extends PelEntryNumber {
  133.  
  134.   /**
  135.    * Make a new entry that can hold a signed long.
  136.    *
  137.    * The method accept its arguments in two forms: several integer
  138.    * arguments or a single array argument.  The {@link getValue}
  139.    * method will always return an array except for when a single
  140.    * integer argument is given here, or when an array with just a
  141.    * single integer is given.
  142.    *
  143.    * @param PelTag the tag which this entry represents.  This
  144.    *  should be one of the constants defined in {@link PelTag}
  145.    *  which have format {@link PelFormat::SLONG}.
  146.    *
  147.    * @param int $value... the long(s) that this entry will represent
  148.    *  or an array of longs.  The argument passed must obey the same
  149.    *  rules as the argument to {@link setValue}, namely that it should
  150.    *  be within range of a signed long (32 bit), that is between
  151.    *  -2147483648 and 2147483647 (inclusive).  If not, then a {@link }
  152.    *  PelOverflowException} will be thrown.
  153.    */
  154.   function __construct($tag /* $value... */{
  155.     $this->tag    = $tag;
  156.     $this->min    = -2147483648;
  157.     $this->max    = 2147483647;
  158.     $this->format = PelFormat::SLONG;
  159.  
  160.     $value func_get_args();
  161.     array_shift($value);
  162.     $this->setValueArray($value);
  163.   }
  164.  
  165.  
  166.   /**
  167.    * Convert a number into bytes.
  168.    *
  169.    * @param int the number that should be converted.
  170.    *
  171.    * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  172.    *  {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  173.    *
  174.    * @return string bytes representing the number given.
  175.    */
  176.   function numberToBytes($number$order{
  177.     return PelConvert::sLongToBytes($number$order);
  178.   }
  179. }
  180.  
  181.  
  182. ?>

Documentation generated on Thu, 05 May 2011 07:19:03 +0200 by phpDocumentor 1.4.3