public void testCreateBanded() {
    int[] bankIndices = new int[] {0, 1, 2};
    int[] bandOffsets = new int[] {1, 1, 1};
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int dataType = DataBuffer.TYPE_BYTE;
    boolean hasAlpha = false;

    ImageTypeSpecifier typeSpecifier =
        ImageTypeSpecifier.createBanded(
            colorSpace, bankIndices, bandOffsets, dataType, hasAlpha, false);

    ColorModel colorModel = typeSpecifier.getColorModel();
    assertEquals(
        "Failed to create with the correct colorspace type",
        ColorSpace.TYPE_RGB,
        colorModel.getColorSpace().getType());
    assertEquals(
        "Failed to create with the correct transparency",
        Transparency.OPAQUE,
        colorModel.getTransparency());
    assertEquals(
        "Failed to create with the correcttransfer type",
        DataBuffer.TYPE_BYTE,
        colorModel.getTransferType());

    BandedSampleModel sampleModel = (BandedSampleModel) typeSpecifier.getSampleModel();
    assertArrayEquals(
        "Failed to create with the correct bankIndices", bankIndices, sampleModel.getBankIndices());
    assertArrayEquals(
        "Failed to create with the correct bankIndices", bandOffsets, sampleModel.getBandOffsets());
  }
  public void testCreateInterleaved() {
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] bandOffsets = new int[] {1, 2, 3};
    int dataType = DataBuffer.TYPE_BYTE;

    ImageTypeSpecifier type =
        ImageTypeSpecifier.createInterleaved(colorSpace, bandOffsets, dataType, false, false);
    ColorModel colorModel = type.getColorModel();
    PixelInterleavedSampleModel sampleModel = (PixelInterleavedSampleModel) type.getSampleModel();

    // validate the colorModel
    assertEquals(
        "Failed to create with the correct colorspace type",
        ColorSpace.TYPE_RGB,
        colorModel.getColorSpace().getType());
    assertEquals(
        "Failed to create with the correct transparency",
        Transparency.OPAQUE,
        colorModel.getTransparency());
    assertEquals(
        "Failed to create with the correct transfer type",
        DataBuffer.TYPE_BYTE,
        colorModel.getTransferType());

    // validate the sampleModel
    assertTrue(
        "The sampleModel and colorModel are not compatible",
        colorModel.isCompatibleSampleModel(sampleModel));
    assertArrayEquals(
        "Failed to create with the correct bandOffsets", bandOffsets, sampleModel.getBandOffsets());
    assertEquals("Failed to create with the correct pixel stride", 3, sampleModel.getPixelStride());
  }
  public void testCreateBufferedImage() {
    ImageTypeSpecifier typeSpecifier =
        ImageTypeSpecifier.createGrayscale(8, DataBuffer.TYPE_BYTE, true);

    int width = 10;
    int height = 10;
    BufferedImage image = typeSpecifier.createBufferedImage(width, height);
    assertEquals(
        "Failed to create with the correct ColorModel",
        typeSpecifier.getColorModel(),
        image.getColorModel());
    assertEquals(
        "Failed to create with the correct SampleModel",
        typeSpecifier.getSampleModel().getClass(),
        image.getSampleModel().getClass());
    assertEquals("Failed to create with the correct width", width, image.getWidth());
    assertEquals("Failed to create with the correct height", height, image.getHeight());
  }