Java Code Examples for java.awt.image.BufferedImage.TYPE_BYTE_INDEXED

The following are Jave code examples for showing how to use TYPE_BYTE_INDEXED of the java.awt.image.BufferedImage class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: BMPSubsamplingTest.java   View Source Code Vote up 6 votes
private BufferedImage createIndexImage(int bpp) {
    // calculate palette size
    int psize = (1 << bpp);

    // prepare palette;
    byte[] r = new byte[psize];
    byte[] g = new byte[psize];
    byte[] b = new byte[psize];

    for (int i = 0; i < colors.length; i++) {
        r[i] = (byte)(0xff & colors[i].getRed());
        g[i] = (byte)(0xff & colors[i].getGreen());
        b[i] = (byte)(0xff & colors[i].getBlue());
    }

    // now prepare appropriate index clor model
    IndexColorModel icm = new IndexColorModel(bpp, psize, r, g, b);

    return new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
}
 
Example 2
Project: openjdk-jdk10   File: OpCompatibleImageTest.java   View Source Code Vote up 6 votes
public void doTest(int type) {
    System.out.println("Test for type " + describeType(type));

    BufferedImage src = createTestImage(type);

    BufferedImage res = null;

    System.out.println("Testing null destination...");
    try {
        res = op.filter(src, null);
    } catch (ImagingOpException e) {
        throw new RuntimeException("Test FAILED!", e);
    }

    if (res == null ||
        ((src.getType() != BufferedImage.TYPE_BYTE_INDEXED) &&
         (res.getType() != src.getType())))
    {
        throw new RuntimeException("Test FAILED!");
    }
    System.out.println("Test PASSED.");
}
 
Example 3
Project: OpenJSharp   File: GIFImageReader.java   View Source Code Vote up 6 votes
private static synchronized byte[] getDefaultPalette() {
    if (defaultPalette == null) {
        BufferedImage img = new BufferedImage(1, 1,
                BufferedImage.TYPE_BYTE_INDEXED);
        IndexColorModel icm = (IndexColorModel) img.getColorModel();

        final int size = icm.getMapSize();
        byte[] r = new byte[size];
        byte[] g = new byte[size];
        byte[] b = new byte[size];
        icm.getReds(r);
        icm.getGreens(g);
        icm.getBlues(b);

        defaultPalette = new byte[size * 3];

        for (int i = 0; i < size; i++) {
            defaultPalette[3 * i + 0] = r[i];
            defaultPalette[3 * i + 1] = g[i];
            defaultPalette[3 * i + 2] = b[i];
        }
    }
    return defaultPalette;
}
 
Example 4
Project: ChessBot   File: ChessBoardUtils.java   View Source Code Vote up 6 votes
public static BufferedImage blur(BufferedImage src) {
    BufferedImage bufferedImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);

    int s1 = 7;
    int s2 = 7;
    float level = .1f / 9f;

    float[] filter = new float[s1 * s2];

    for (int i = 0; i < s1 * s2; i++) {
        filter[i] = level;
    }

    Kernel kernel = new Kernel(s1, s2, filter);
    BufferedImageOp op = new ConvolveOp(kernel);
    bufferedImage = op.filter(src, null);

    return bufferedImage;
}
 
Example 5
Project: jdk8u-jdk   File: GIFImageReader.java   View Source Code Vote up 6 votes
private static synchronized byte[] getDefaultPalette() {
    if (defaultPalette == null) {
        BufferedImage img = new BufferedImage(1, 1,
                BufferedImage.TYPE_BYTE_INDEXED);
        IndexColorModel icm = (IndexColorModel) img.getColorModel();

        final int size = icm.getMapSize();
        byte[] r = new byte[size];
        byte[] g = new byte[size];
        byte[] b = new byte[size];
        icm.getReds(r);
        icm.getGreens(g);
        icm.getBlues(b);

        defaultPalette = new byte[size * 3];

        for (int i = 0; i < size; i++) {
            defaultPalette[3 * i + 0] = r[i];
            defaultPalette[3 * i + 1] = g[i];
            defaultPalette[3 * i + 2] = b[i];
        }
    }
    return defaultPalette;
}
 
Example 6
Project: jdk8u-jdk   File: PaletteBuilder.java   View Source Code Vote up 6 votes
protected RenderedImage getIndexedImage() {
    IndexColorModel icm = getIndexColorModel();

    BufferedImage dst =
        new BufferedImage(src.getWidth(), src.getHeight(),
                          BufferedImage.TYPE_BYTE_INDEXED, icm);

    WritableRaster wr = dst.getRaster();
    for (int y =0; y < dst.getHeight(); y++) {
        for (int x = 0; x < dst.getWidth(); x++) {
            Color aColor = getSrcColor(x,y);
            wr.setSample(x, y, 0, findColorIndex(root, aColor));
        }
    }

    return dst;
}
 
Example 7
Project: openjdk-jdk10   File: EncodeSubImageTest.java   View Source Code Vote up 6 votes
private static BufferedImage createTestImage() {
    int w = 100;
    int h = 100;

    BufferedImage src = new BufferedImage(w, h,
            BufferedImage.TYPE_BYTE_INDEXED);
    Graphics g = src.createGraphics();
    g.setColor(Color.red);
    g.fillRect(0, 0, w, h);
    g.setColor(Color.green);
    g.fillRect(subImageOffset, subImageOffset,
            w - 2 * subImageOffset, h - 2* subImageOffset);
    g.setColor(Color.blue);
    g.fillRect(2 * subImageOffset, 2 * subImageOffset,
            w - 4 * subImageOffset, h - 4 * subImageOffset);
    g.dispose();

    return src;
}
 
Example 8
Project: jdk8u-jdk   File: OpCompatibleImageTest.java   View Source Code Vote up 6 votes
public void doTest(int type) {
    System.out.println("Test for type " + describeType(type));

    BufferedImage src = createTestImage(type);

    BufferedImage res = null;

    System.out.println("Testing null destination...");
    try {
        res = op.filter(src, null);
    } catch (ImagingOpException e) {
        throw new RuntimeException("Test FAILED!", e);
    }

    if (res == null ||
        ((src.getType() != BufferedImage.TYPE_BYTE_INDEXED) &&
         (res.getType() != src.getType())))
    {
        throw new RuntimeException("Test FAILED!");
    }
    System.out.println("Test PASSED.");
}
 
Example 9
Project: openjdk-jdk10   File: RleEncodingTest.java   View Source Code Vote up 6 votes
private static void encodeRLE8Test() throws IOException {
    // create 8bpp image
    byte[] r = new byte[256];
    r[0] = (byte)0xff;
    byte[] g = new byte[256];
    g[1] = (byte)0xff;
    byte[] b = new byte[256];
    b[2] = (byte)0xff;
    IndexColorModel icm = new IndexColorModel(8, 256, r, g, b);

    BufferedImage bimg = new BufferedImage(100, 100,
                                           BufferedImage.TYPE_BYTE_INDEXED,
                                           icm);
    Graphics gr = bimg.getGraphics();
    gr.setColor(Color.green);
    gr.fillRect(0, 0, 100, 100);

    doTest(bimg, "BI_RLE8", ImageWriteParam.MODE_EXPLICIT);
}
 
Example 10
Project: openjdk-jdk10   File: GIFImageReader.java   View Source Code Vote up 6 votes
private static synchronized byte[] getDefaultPalette() {
    if (defaultPalette == null) {
        BufferedImage img = new BufferedImage(1, 1,
                BufferedImage.TYPE_BYTE_INDEXED);
        IndexColorModel icm = (IndexColorModel) img.getColorModel();

        final int size = icm.getMapSize();
        byte[] r = new byte[size];
        byte[] g = new byte[size];
        byte[] b = new byte[size];
        icm.getReds(r);
        icm.getGreens(g);
        icm.getBlues(b);

        defaultPalette = new byte[size * 3];

        for (int i = 0; i < size; i++) {
            defaultPalette[3 * i + 0] = r[i];
            defaultPalette[3 * i + 1] = g[i];
            defaultPalette[3 * i + 2] = b[i];
        }
    }
    return defaultPalette;
}
 
Example 11
Project: openjdk-jdk10   File: ColConvTest.java   View Source Code Vote up 6 votes
static String getImageTypeName(int type) {
    switch(type) {
        case BufferedImage.TYPE_INT_ARGB:
            return "TYPE_INT_ARGB";
        case BufferedImage.TYPE_INT_RGB:
            return "TYPE_INT_RGB";
        case BufferedImage.TYPE_INT_BGR:
            return "TYPE_INT_BGR";
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return "TYPE_INT_ARGB_PRE";
        case BufferedImage.TYPE_3BYTE_BGR:
            return "TYPE_3BYTE_BGR";
        case BufferedImage.TYPE_4BYTE_ABGR:
            return "TYPE_4BYTE_ABGR";
        case BufferedImage.TYPE_4BYTE_ABGR_PRE:
            return "TYPE_4BYTE_ABGR_PRE";
        case BufferedImage.TYPE_BYTE_BINARY:
            return "TYPE_BYTE_BINARY";
        case BufferedImage.TYPE_BYTE_GRAY:
            return "TYPE_BYTE_GRAY";
        case BufferedImage.TYPE_BYTE_INDEXED:
            return "TYPE_BYTE_INDEXED";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "TYPE_USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "TYPE_USHORT_565_RGB";
        case BufferedImage.TYPE_USHORT_GRAY:
            return "TYPE_USHORT_GRAY";
    }
    return "UNKNOWN";
}
 
Example 12
Project: OpenJSharp   File: Destinations.java   View Source Code Vote up 5 votes
public static void init() {
    destroot = new Group.EnableSet(TestEnvironment.globaloptroot,
                                   "dest", "Output Destination Options");

    new Screen();
    new OffScreen();

    if (GraphicsTests.hasGraphics2D) {
        if (ImageTests.hasCompatImage) {
            compatimgdestroot =
                new Group.EnableSet(destroot, "compatimg",
                                    "Compatible Image Destinations");
            compatimgdestroot.setHorizontal();

            new CompatImg();
            new CompatImg(Transparency.OPAQUE);
            new CompatImg(Transparency.BITMASK);
            new CompatImg(Transparency.TRANSLUCENT);
        }

        if (ImageTests.hasVolatileImage) {
            new VolatileImg();
        }

        bufimgdestroot = new Group.EnableSet(destroot, "bufimg",
                                             "BufferedImage Destinations");

        new BufImg(BufferedImage.TYPE_INT_RGB);
        new BufImg(BufferedImage.TYPE_INT_ARGB);
        new BufImg(BufferedImage.TYPE_INT_ARGB_PRE);
        new BufImg(BufferedImage.TYPE_3BYTE_BGR);
        new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
        new BufImg(BufferedImage.TYPE_BYTE_GRAY);
        new CustomImg();
    }
}
 
Example 13
Project: openjdk-jdk10   File: ConvertToByteIndexedTest.java   View Source Code Vote up 5 votes
public static void ConvertToByteIndexed(Color color, int srcType) {
    // setup source image and graphics for conversion.
    BufferedImage srcImage = new BufferedImage(width, height, srcType);
    Graphics2D srcG2D = srcImage.createGraphics();
    srcG2D.setColor(color);
    srcG2D.fillRect(0, 0, width, height);

    // setup destination image and graphics for conversion.
    int dstType = BufferedImage.TYPE_BYTE_INDEXED;
    BufferedImage dstImage = new BufferedImage(width, height, dstType);
    Graphics2D dstG2D = (Graphics2D)dstImage.getGraphics();
    // draw source image into Byte Indexed destination
    dstG2D.drawImage(srcImage, 0, 0, null);

    // draw into ARGB image to verify individual pixel value.
    BufferedImage argbImage = new BufferedImage(width, height,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D argbG2D = (Graphics2D)argbImage.getGraphics();
    argbG2D.drawImage(dstImage, 0, 0, null);

    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            if (color.getRGB() != argbImage.getRGB(i, j)) {
                throw new RuntimeException("Conversion from " +
                        TYPE_TABLE.get(srcType) + " to BYTE_INDEXED is not"
                        + " done properly for " + color);
            }
        }
    }
}
 
Example 14
Project: jdk8u-jdk   File: Destinations.java   View Source Code Vote up 5 votes
public static void init() {
    destroot = new Group.EnableSet(TestEnvironment.globaloptroot,
                                   "dest", "Output Destination Options");

    new Screen();
    new OffScreen();

    if (GraphicsTests.hasGraphics2D) {
        if (ImageTests.hasCompatImage) {
            compatimgdestroot =
                new Group.EnableSet(destroot, "compatimg",
                                    "Compatible Image Destinations");
            compatimgdestroot.setHorizontal();

            new CompatImg();
            new CompatImg(Transparency.OPAQUE);
            new CompatImg(Transparency.BITMASK);
            new CompatImg(Transparency.TRANSLUCENT);
        }

        if (ImageTests.hasVolatileImage) {
            new VolatileImg();
        }

        bufimgdestroot = new Group.EnableSet(destroot, "bufimg",
                                             "BufferedImage Destinations");

        new BufImg(BufferedImage.TYPE_INT_RGB);
        new BufImg(BufferedImage.TYPE_INT_ARGB);
        new BufImg(BufferedImage.TYPE_INT_ARGB_PRE);
        new BufImg(BufferedImage.TYPE_3BYTE_BGR);
        new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
        new BufImg(BufferedImage.TYPE_BYTE_GRAY);
        new CustomImg();
    }
}
 
Example 15
Project: openjdk-jdk10   File: WriterReuseTest.java   View Source Code Vote up 5 votes
public static BufferedImage createTestImage() {
    BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_INDEXED);
    Graphics g = img.createGraphics();
    g.setColor(Color.black);
    g.fillRect(0, 0, 100, 100);

    g.setColor(Color.white);
    g.fillRect(10, 10, 80, 80);

    return img;
}
 
Example 16
Project: jdk8u-jdk   File: BMPSubsamplingTest.java   View Source Code Vote up 5 votes
private String getImageTypeName(int t) {
    switch(t) {
      case BufferedImage.TYPE_INT_RGB:
          return "TYPE_INT_RGB";
      case BufferedImage.TYPE_INT_BGR:
          return "TYPE_INT_BGR";
      case TYPE_INT_GRB:
          return "TYPE_INT_GRB";
      case TYPE_INT_GBR:
          return "TYPE_INT_GBR";
      case TYPE_INT_RBG:
          return "TYPE_INT_RBG";
      case TYPE_INT_BRG:
          return "TYPE_INT_BRG";
      case BufferedImage.TYPE_USHORT_555_RGB:
          return "TYPE_USHORT_555_RGB";
      case BufferedImage.TYPE_USHORT_565_RGB:
          return "TYPE_USHORT_565_RGB";
      case TYPE_USHORT_555_GRB:
          return "TYPE_USHORT_555_GRB";
      case TYPE_USHORT_555_BGR:
          return "TYPE_USHORT_555_BGR";
      case TYPE_USHORT_565_BGR:
          return "TYPE_USHORT_565_BGR";
      case BufferedImage.TYPE_3BYTE_BGR:
          return "TYPE_3BYTE_BGR";
      case TYPE_3BYTE_RGB:
          return "TYPE_3BYTE_RGB";
      case TYPE_3BYTE_GRB:
          return "TYPE_3BYTE_GRB";
      case BufferedImage.TYPE_BYTE_INDEXED:
          return "TYPE_BYTE_INDEXED";
      case TYPE_4BPP_INDEXED:
          return "TYPE_BYTE_INDEXED (4bpp)";
      default:
          throw new IllegalArgumentException("Unknown image type: " + t);
    }
}
 
Example 17
Project: openjdk-jdk10   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 18
Project: OpenJSharp   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 19
Project: jdk8u-jdk   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 20
Project: OpenJSharp   File: ImageTypeSpecifier.java   View Source Code Vote up 3 votes
/**
 * Returns an <code>ImageTypeSpecifier</code> that encodes
 * one of the standard <code>BufferedImage</code> types
 * (other than <code>TYPE_CUSTOM</code>).
 *
 * @param bufferedImageType an int representing one of the standard
 * <code>BufferedImage</code> types.
 *
 * @return an <code>ImageTypeSpecifier</code> with the desired
 * characteristics.
 *
 * @exception IllegalArgumentException if
 * <code>bufferedImageType</code> is not one of the standard
 * types, or is equal to <code>TYPE_CUSTOM</code>.
 *
 * @see java.awt.image.BufferedImage
 * @see java.awt.image.BufferedImage#TYPE_INT_RGB
 * @see java.awt.image.BufferedImage#TYPE_INT_ARGB
 * @see java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE
 * @see java.awt.image.BufferedImage#TYPE_INT_BGR
 * @see java.awt.image.BufferedImage#TYPE_3BYTE_BGR
 * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR
 * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR_PRE
 * @see java.awt.image.BufferedImage#TYPE_USHORT_565_RGB
 * @see java.awt.image.BufferedImage#TYPE_USHORT_555_RGB
 * @see java.awt.image.BufferedImage#TYPE_BYTE_GRAY
 * @see java.awt.image.BufferedImage#TYPE_USHORT_GRAY
 * @see java.awt.image.BufferedImage#TYPE_BYTE_BINARY
 * @see java.awt.image.BufferedImage#TYPE_BYTE_INDEXED
 */
public static
    ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType) {
    if (bufferedImageType >= BufferedImage.TYPE_INT_RGB &&
        bufferedImageType <= BufferedImage.TYPE_BYTE_INDEXED) {
        return getSpecifier(bufferedImageType);
    } else if (bufferedImageType == BufferedImage.TYPE_CUSTOM) {
        throw new IllegalArgumentException("Cannot create from TYPE_CUSTOM!");
    } else {
        throw new IllegalArgumentException("Invalid BufferedImage type!");
    }
}