예제 #1
0
 /**
  * Return a signed short read from the data.
  *
  * @param
  *            int the offset into the data. An offset of zero will
  *            return the first short available in the current allowed window.
  *            The last valid offset is equal to {@link getSize()}-2. Invalid
  *            offsets will result in a {@link PelDataWindowOffsetException}
  *            being thrown.
  *
  * @return int the signed short found at offset.
  */
 public function getSShort($o = 0)
 {
     /*
      * Validate the offset+1 to see if we can safely get two bytes ---
      * this throws an exception if offset is out of range.
      */
     $this->validateOffset($o);
     $this->validateOffset($o + 1);
     /* Translate the offset into an offset into the data. */
     $o += $this->start;
     /* Return a signed short. */
     return PelConvert::bytesToSShort($this->data, $o, $this->order);
 }
예제 #2
0
 function testSShortBig()
 {
     $o = PelConvert::BIG_ENDIAN;
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 0, $o), 0);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 1, $o), 0);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 2, $o), 0);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 3, $o), 1);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 4, $o), 291);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 5, $o), 9029);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 6, $o), 17767);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 7, $o), 26505);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 8, $o), -30293);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 9, $o), -21555);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 10, $o), -12817);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 11, $o), -4097);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 12, $o), -1);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 13, $o), -1);
     $this->assertEqual(PelConvert::bytesToSShort($this->bytes, 14, $o), -1);
 }