4 * PEL: PHP Exif Library.
5 * A library with support for reading and
6 * writing all Exif headers in JPEG and TIFF images using PHP.
8 * Copyright (C) 2004, 2005, 2006 Martin Geisler.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program in the file COPYING; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
25 namespace lsolesen\pel;
28 * Classes used to hold shorts, both signed and unsigned.
30 * @author Martin Geisler <mgeisler@users.sourceforge.net>
31 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
37 * Class for holding signed shorts.
39 * This class can hold shorts, either just a single short or an array
40 * of shorts. The class will be used to manipulate any of the Exif
41 * tags which has format {@link PelFormat::SSHORT}.
43 * @author Martin Geisler <mgeisler@users.sourceforge.net>
46 class PelEntrySShort extends PelEntryNumber
50 * Make a new entry that can hold a signed short.
52 * The method accept several integer arguments. The {@link
53 * getValue} method will always return an array except for when a
54 * single integer argument is given here.
57 * the tag which this entry represents. This
58 * should be one of the constants defined in {@link PelTag}
59 * which has format {@link PelFormat::SSHORT}.
61 * @param int $value...
62 * the signed short(s) that this entry will
63 * represent. The argument passed must obey the same rules as the
64 * argument to {@link setValue}, namely that it should be within
65 * range of a signed short, that is between -32768 to 32767
66 * (inclusive). If not, then a {@link PelOverFlowException} will be
69 public function __construct($tag, $value = null)
74 $this->format = PelFormat::SSHORT;
76 $value = func_get_args();
78 $this->setValueArray($value);
82 * Convert a number into bytes.
85 * the number that should be converted.
87 * @param PelByteOrder $order
88 * one of {@link PelConvert::LITTLE_ENDIAN} and
89 * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
91 * @return string bytes representing the number given.
93 public function numberToBytes($number, $order)
95 return PelConvert::sShortToBytes($number, $order);