Source for file PelEntryByte.php

Documentation is available at PelEntryByte.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. /* PelEntryByte.php,v 1.4 2004/06/26 20:39:10 gimpster Exp */
  25.  
  26.  
  27. /**
  28. * Classes used to hold bytes, 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 bytes.
  41. *
  42. * This class can hold bytes, either just a single byte or an array of
  43. * bytes. The class will be used to manipulate any of the EXIF tags
  44. * which has format {@link PelFormat::BYTE}.
  45. *
  46. * @author Martin Geisler <gimpster@users.sourceforge.net>
  47. * @package PEL
  48. */
  49. class PelEntryByte extends PelEntryNumber {
  50.  
  51. /**
  52. * Make a new entry that can hold an unsigned byte.
  53. *
  54. * The method accept several integer arguments. The {@link }
  55. * getValue} method will always return an array except for when a
  56. * single integer argument is given here.
  57. *
  58. * @param PelTag the tag which this entry represents. This
  59. * should be one of the constants defined in {@link PelTag}
  60. * which has format {@link PelFormat::BYTE}.
  61. *
  62. * @param int $value... the byte(s) that this entry will represent.
  63. * The argument passed must obey the same rules as the argument to
  64. * {@link setValue}, namely that it should be within range of an
  65. * unsigned byte, that is between 0 and 255 (inclusive). If not,
  66. * then a {@link PelOverflowException} will be thrown.
  67. */
  68. function __construct($tag /* ... */) {
  69. $this->tag = $tag;
  70. $this->min = 0;
  71. $this->max = 255;
  72. $this->format = PelFormat::BYTE;
  73.  
  74. $value = func_get_args();
  75. array_shift($value);
  76. $this->setValueArray($value);
  77. }
  78.  
  79.  
  80. /**
  81. * Convert a number into bytes.
  82. *
  83. * @param int the number that should be converted.
  84. *
  85. * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  86. * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  87. *
  88. * @return string bytes representing the number given.
  89. */
  90. function numberToBytes($number, $order) {
  91. return chr($number);
  92. }
  93.  
  94. }
  95.  
  96.  
  97. /**
  98. * Class for holding signed bytes.
  99. *
  100. * This class can hold bytes, either just a single byte or an array of
  101. * bytes. The class will be used to manipulate any of the EXIF tags
  102. * which has format {@link PelFormat::BYTE}.
  103. *
  104. * @author Martin Geisler <gimpster@users.sourceforge.net>
  105. * @package PEL
  106. */
  107. class PelEntrySByte extends PelEntryNumber {
  108.  
  109. /**
  110. * Make a new entry that can hold a signed byte.
  111. *
  112. * The method accept several integer arguments. The {@link getValue}
  113. * method will always return an array except for when a single
  114. * integer argument is given here.
  115. *
  116. * @param PelTag the tag which this entry represents. This
  117. * should be one of the constants defined in {@link PelTag}
  118. * which has format {@link PelFormat::BYTE}.
  119. *
  120. * @param int $value... the byte(s) that this entry will represent.
  121. * The argument passed must obey the same rules as the argument to
  122. * {@link setValue}, namely that it should be within range of a
  123. * signed byte, that is between -128 and 127 (inclusive). If not,
  124. * then a {@link PelOverflowException} will be thrown.
  125. */
  126. function __construct($tag /* ... */) {
  127. $this->tag = $tag;
  128. $this->min = -128;
  129. $this->max = 127;
  130. $this->format = PelFormat::SBYTE;
  131.  
  132. $value = func_get_args();
  133. array_shift($value);
  134. $this->setValueArray($value);
  135. }
  136.  
  137.  
  138. /**
  139. * Convert a number into bytes.
  140. *
  141. * @param int the number that should be converted.
  142. *
  143. * @param PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
  144. * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
  145. *
  146. * @return string bytes representing the number given.
  147. */
  148. function numberToBytes($number, $order) {
  149. return chr($number);
  150. }
  151.  
  152. }
  153.  
  154.  
  155. ?>

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