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

SourceForge.net Logo Documentation generated on Wed, 21 Jul 2004 19:13:01 +0200 by phpDocumentor 1.3.0RC3