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: PelEntryLong.php 419 2006-02-20 16:22:36Z mgeisler $ */
  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: 419 $
  32.  * @date $Date: 2006-02-20 17:22:36 +0100 (Mon, 20 Feb 2006) $
  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.  * Class for holding unsigned longs.
  44.  *
  45.  * This class can hold longs, either just a single long or an array of
  46.  * longs.  The class will be used to manipulate any of the Exif tags
  47.  * which can have format {@link PelFormat::LONG} like in this
  48.  * example:
  49.  * <code>
  50.  * $w = $ifd->getEntry(PelTag::EXIF_IMAGE_WIDTH);
  51.  * $w->setValue($w->getValue() / 2);
  52.  * $h = $ifd->getEntry(PelTag::EXIF_IMAGE_HEIGHT);
  53.  * $h->setValue($h->getValue() / 2);
  54.  * </code>
  55.  * Here the width and height is updated to 50% of their original
  56.  * values.
  57.  *
  58.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  59.  * @package PEL
  60.  */
  61. class PelEntryLong extends PelEntryNumber {
  62.  
  63.   /**
  64.    * Make a new entry that can hold an unsigned long.
  65.    *
  66.    * The method accept its arguments in two forms: several integer
  67.    * arguments or a single array argument.  The {@link getValue}
  68.    * method will always return an array except for when a single
  69.    * integer argument is given here, or when an array with just a
  70.    * single integer is given.
  71.    *
  72.    * This means that one can conveniently use objects like this:
  73.    * <code>
  74.    * $a = new PelEntryLong(PelTag::EXIF_IMAGE_WIDTH, 123456);
  75.    * $b = $a->getValue() - 654321;
  76.    * </code>
  77.    * where the call to {@link getValue} will return an integer instead
  78.    * of an array with one integer element, which would then have to be
  79.    * extracted.
  80.    *
  81.    * @param PelTag the tag which this entry represents.  This
  82.    *  should be one of the constants defined in {@link PelTag},
  83.    *  e.g., {@link PelTag::IMAGE_WIDTH}, or any other tag which can
  84.    *  have format {@link PelFormat::LONG}.
  85.    *
  86.    * @param int $value... the long(s) that this entry will
  87.    *  represent or an array of longs.  The argument passed must obey
  88.    *  the same rules as the argument to {@link setValue}, namely that
  89.    *  it should be within range of an unsigned long (32 bit), that is
  90.    *  between 0 and 4294967295 (inclusive).  If not, then a {@link }
  91.    *  PelExifOverflowException} will be thrown.
  92.    */
  93.   function __construct($tag /* $value... */{
  94.     $this->tag    = $tag;
  95.     $this->min    = 0;
  96.     $this->max    = 4294967295;
  97.     $this->format = PelFormat::LONG;
  98.  
  99.     $value func_get_args();
  100.     array_shift($value);
  101.     $this->setValueArray($value);
  102.   }
  103.  
  104.  
  105.   /**
  106.    * Convert a number into bytes.
  107.    *
  108.    * @param int the number that should be converted.
  109.    *
  110.    * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  111.    *  {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  112.    *
  113.    * @return string bytes representing the number given.
  114.    */
  115.   function numberToBytes($number$order{
  116.     return PelConvert::longToBytes($number$order);
  117.   }
  118. }
  119.  
  120.  
  121. /**
  122.  * Class for holding signed longs.
  123.  *
  124.  * This class can hold longs, either just a single long or an array of
  125.  * longs.  The class will be used to manipulate any of the Exif tags
  126.  * which can have format {@link PelFormat::SLONG}.
  127.  *
  128.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  129.  * @package PEL
  130.  */
  131. class PelEntrySLong extends PelEntryNumber {
  132.  
  133.   /**
  134.    * Make a new entry that can hold a signed long.
  135.    *
  136.    * The method accept its arguments in two forms: several integer
  137.    * arguments or a single array argument.  The {@link getValue}
  138.    * method will always return an array except for when a single
  139.    * integer argument is given here, or when an array with just a
  140.    * single integer is given.
  141.    *
  142.    * @param PelTag the tag which this entry represents.  This
  143.    *  should be one of the constants defined in {@link PelTag}
  144.    *  which have format {@link PelFormat::SLONG}.
  145.    *
  146.    * @param int $value... the long(s) that this entry will represent
  147.    *  or an array of longs.  The argument passed must obey the same
  148.    *  rules as the argument to {@link setValue}, namely that it should
  149.    *  be within range of a signed long (32 bit), that is between
  150.    *  -2147483648 and 2147483647 (inclusive).  If not, then a {@link }
  151.    *  PelOverflowException} will be thrown.
  152.    */
  153.   function __construct($tag /* $value... */{
  154.     $this->tag    = $tag;
  155.     $this->min    = -2147483648;
  156.     $this->max    = 2147483647;
  157.     $this->format = PelFormat::SLONG;
  158.  
  159.     $value func_get_args();
  160.     array_shift($value);
  161.     $this->setValueArray($value);
  162.   }
  163.  
  164.  
  165.   /**
  166.    * Convert a number into bytes.
  167.    *
  168.    * @param int the number that should be converted.
  169.    *
  170.    * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  171.    *  {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  172.    *
  173.    * @return string bytes representing the number given.
  174.    */
  175.   function numberToBytes($number$order{
  176.     return PelConvert::sLongToBytes($number$order);
  177.   }
  178. }
  179.  
  180.  
  181. ?>

Documentation generated on Tue, 19 Dec 2006 01:08:20 +0100 by phpDocumentor 1.3.0 SourceForge.net Logo