test_class.file: apps/dcm4che/dcm4che-2.0.25-src/dcm4che-image/src/test/java/org/dcm4che2/image/OverlayUtilsTest.java
test_class.identifier: OverlayUtilsTest
test_case.body: @Test
      public void padToFixRowByteBoundary_WhenInputIs12BytesRows5Cols18_ShouldPadCorrectly() {
          byte[] inputArray = new byte[] { (byte) 0xAB, (byte)0xCD, (byte) 0xEF, (byte) 0xBA, (byte) 0xDC, (byte) 0xAB, (byte)0xCD, (byte) 0xEF, (byte) 0xBA, (byte) 0xDC, (byte) 0xAB, (byte)0xCD }; 
          byte[] expectedArray = new byte[] { (byte) 0xAB, (byte)0xCD, (byte) 0xEF, (byte) 0xBB, (byte) 0x2E, (byte) 0xF7, (byte)0xBD, (byte) 0xDA, (byte) 0xFC, (byte) 0xBF, (byte) 0xEB, (byte)0x72, (byte)0xDC, (byte)0xAB, (byte)0xCD }; 
          byte[] actualArray = OverlayUtils.padToFixRowByteBoundary(inputArray, 5, 18);
          
          checkArrays(expectedArray, actualArray);
      }
test_case.class_method_signature: OverlayUtilsTest.padToFixRowByteBoundary_WhenInputIs12BytesRows5Cols18_ShouldPadCorrectly()
test_case.full_signature: @Test public void padToFixRowByteBoundary_WhenInputIs12BytesRows5Cols18_ShouldPadCorrectly()
test_case.identifier: padToFixRowByteBoundary_WhenInputIs12BytesRows5Cols18_ShouldPadCorrectly
test_case.invocations: padToFixRowByteBoundary checkArrays
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void padToFixRowByteBoundary_WhenInputIs12BytesRows5Cols18_ShouldPadCorrectly()
focal_class.declarator: BITS_PER_BYTE = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int BITS_PER_BYTE = 8;
focal_class.type: int
focal_class.var_name: BITS_PER_BYTE
focal_class.declarator: reorderBytes
focal_class.modifier: private static
focal_class.original_string: private static LookupTable reorderBytes;
focal_class.type: LookupTable
focal_class.var_name: reorderBytes
focal_class.declarator: rgbArr = new byte[] { (byte) 0xFF, 0 }
focal_class.modifier: private static
focal_class.original_string: private static byte[] rgbArr = new byte[] { (byte) 0xFF, 0 };
focal_class.type: byte[]
focal_class.var_name: rgbArr
focal_class.declarator: aArr = new byte[] { (byte) 0x00, (byte) 0xFF }
focal_class.modifier: private static
focal_class.original_string: private static byte[] aArr = new byte[] { (byte) 0x00, (byte) 0xFF };
focal_class.type: byte[]
focal_class.var_name: aArr
focal_class.file: apps/dcm4che/dcm4che-2.0.25-src/dcm4che-image/src/main/java/org/dcm4che2/image/OverlayUtils.java
focal_class.identifier: OverlayUtils
focal_class.class_method_signature: OverlayUtils.isOverlay(int imageIndex)
focal_class.full_signature: public static boolean isOverlay(int imageIndex)
focal_class.identifier: isOverlay
focal_class.modifiers: public static
focal_class.parameters: (int imageIndex)
focal_class.return: boolean
focal_class.signature: boolean isOverlay(int imageIndex)
focal_class.class_method_signature: OverlayUtils.extractFrameNumber(int imageIndex)
focal_class.full_signature: public static int extractFrameNumber(int imageIndex)
focal_class.identifier: extractFrameNumber
focal_class.modifiers: public static
focal_class.parameters: (int imageIndex)
focal_class.return: int
focal_class.signature: int extractFrameNumber(int imageIndex)
focal_class.class_method_signature: OverlayUtils.extractOverlay(DicomObject ds,
              int overlayNumber, ImageReader reader, String rgbs)
focal_class.full_signature: public static BufferedImage extractOverlay(DicomObject ds,
              int overlayNumber, ImageReader reader, String rgbs)
focal_class.identifier: extractOverlay
focal_class.modifiers: public static
focal_class.parameters: (DicomObject ds,
              int overlayNumber, ImageReader reader, String rgbs)
focal_class.return: BufferedImage
focal_class.signature: BufferedImage extractOverlay(DicomObject ds,
              int overlayNumber, ImageReader reader, String rgbs)
focal_class.class_method_signature: OverlayUtils.padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
focal_class.full_signature: protected static byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
focal_class.identifier: padToFixRowByteBoundary
focal_class.modifiers: protected static
focal_class.parameters: (byte[] unpaddedData, int rows, int cols)
focal_class.return: byte[]
focal_class.signature: byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
focal_class.class_method_signature: OverlayUtils.getOverlayWidth(DicomObject ds, int overlayNumber)
focal_class.full_signature: public static int getOverlayWidth(DicomObject ds, int overlayNumber)
focal_class.identifier: getOverlayWidth
focal_class.modifiers: public static
focal_class.parameters: (DicomObject ds, int overlayNumber)
focal_class.return: int
focal_class.signature: int getOverlayWidth(DicomObject ds, int overlayNumber)
focal_class.class_method_signature: OverlayUtils.getOverlayHeight(DicomObject ds, int overlayNumber)
focal_class.full_signature: public static int getOverlayHeight(DicomObject ds, int overlayNumber)
focal_class.identifier: getOverlayHeight
focal_class.modifiers: public static
focal_class.parameters: (DicomObject ds, int overlayNumber)
focal_class.return: int
focal_class.signature: int getOverlayHeight(DicomObject ds, int overlayNumber)
focal_method.body: protected static byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols) {
          int numRowBytes = (cols+7)/8;
          int paddedLength = rows * numRowBytes;
          if( (unpaddedData.length == paddedLength ) && (cols%8)==0 ) return unpaddedData;
          
          byte[] data = new byte[paddedLength];
          
          for(int y=0; y<rows; y++) {
              int posnPad = y*numRowBytes;
              int posnUnpad = y*cols;
              // Bits from the current byte needed
              int bits = posnUnpad % 8;
              posnUnpad /= 8;
              int prevBits = 8-bits;
              if( bits==0 ) {
                  // Not only an optimization for performance - also prevents an exception if the last pixel doesn't need 
                  // to overflow from the next unpadded byte...
                  System.arraycopy(unpaddedData,posnUnpad,data, posnPad, numRowBytes);
                  continue;
              }
              int mask = (0xFF << bits) & 0xFF;
              int nextMask = (0xFF >> prevBits) & 0xFF;
              for(int x=0; x<numRowBytes; x++) {
                  try {
                      byte firstByte = (byte) ((unpaddedData[posnUnpad+x] & mask)>>bits);
                      byte secondByte = 0;
                      // The very last byte can use nothing from the next byte if there are unused bits in it
                      if( posnUnpad+x+1 < unpaddedData.length ) secondByte = (byte) ((unpaddedData[posnUnpad+x+1] & nextMask) << prevBits);
                      data[posnPad+x] = (byte) (firstByte | secondByte);
                  } catch (ArrayIndexOutOfBoundsException e) {
                      ArrayIndexOutOfBoundsException newEx = new ArrayIndexOutOfBoundsException(
                              "Did not find enough source data ("+unpaddedData.length+") in overlay to pad data for " 
                              + rows + " rows, " 
                              + cols + "columns");
                      newEx.initCause(e);
                      throw newEx;
                  }
              }
          }
          
          return data;
      }
focal_method.class_method_signature: OverlayUtils.padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
focal_method.full_signature: protected static byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
focal_method.identifier: padToFixRowByteBoundary
focal_method.invocations: arraycopy initCause
focal_method.modifiers: protected static
focal_method.parameters: (byte[] unpaddedData, int rows, int cols)
focal_method.return: byte[]
focal_method.signature: byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)