/**
  * Creates the data byte array for this chunk.
  *
  * @return The data byte array.
  */
 private byte[] createDataBytes() {
   ByteComposer composer = new ByteComposer(13);
   composer.composeInt(width);
   composer.composeInt(height);
   composer.composeInt(sampleDepth, 1);
   composer.composeInt(mode.dataValue(), 1);
   composer.composeInt(compressionEngine.dataValue(), 1);
   composer.composeInt(filterMethod.dataValue(), 1);
   composer.composeInt(interlaceMethod.dataValue(), 1);
   return composer.toArray();
 }
  /**
   * Creates the data byte array from the internal properties.
   *
   * @return The data bytes.
   */
  private byte[] createDataBytes() {
    ByteComposer composer = null;
    switch (mode) {
      case INDEXED:
        composer = new ByteComposer(1);
        composer.composeInt(paletteIndex, 1);
        break;

      case GRAYSCALE:
      case GRAYSCALE_ALPHA:
        composer = new ByteComposer(2);
        composer.composeInt(color.getRed(), 2);
        break;

      case TRUECOLOR:
      case TRUECOLOR_ALPHA:
        composer = new ByteComposer(6);
        composer.composeInt(color.getRed(), 2);
        composer.composeInt(color.getGreen(), 2);
        composer.composeInt(color.getBlue(), 2);
        break;
    }
    return composer.toArray();
  }