Java Code Examples for java.awt.image.BufferedImage#TYPE_USHORT_565_RGB

The following examples show how to use java.awt.image.BufferedImage#TYPE_USHORT_565_RGB . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: scrimage   File: ImageUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static int nrChannels(BufferedImage img) {
   switch (img.getType()) {
      case BufferedImage.TYPE_3BYTE_BGR:
      case BufferedImage.TYPE_INT_BGR:
      case BufferedImage.TYPE_INT_RGB:
      case BufferedImage.TYPE_USHORT_555_RGB:
      case BufferedImage.TYPE_USHORT_565_RGB:
         return 3;
      case BufferedImage.TYPE_4BYTE_ABGR:
      case BufferedImage.TYPE_INT_ARGB:
      case BufferedImage.TYPE_CUSTOM:
      case BufferedImage.TYPE_4BYTE_ABGR_PRE:
      case BufferedImage.TYPE_INT_ARGB_PRE:
         return 4;
      case BufferedImage.TYPE_BYTE_GRAY:
      case BufferedImage.TYPE_USHORT_GRAY:
         return 1;
   }
   return 0;
}
 
Example 2
Source Project: pumpernickel   File: BufferedImageIterator.java    License: MIT License 6 votes vote down vote up
BufferedImageUnknownIterator(BufferedImage bi, boolean topDown) {
	super(bi, topDown);
	if (!(type == BufferedImage.TYPE_BYTE_BINARY
			|| type == BufferedImage.TYPE_CUSTOM
			|| type == BufferedImage.TYPE_USHORT_555_RGB
			|| type == BufferedImage.TYPE_USHORT_565_RGB || type == BufferedImage.TYPE_USHORT_GRAY)) {
		throw new IllegalArgumentException("The image type "
				+ getTypeName(type) + " is not supported.");
	}
	if (warning == false) {
		warning = true;
		System.err
				.println("The BufferedImageUnknownIterator is being used for an image of type "
						+ getTypeName(type)
						+ ".  This is not recommended.");
	}
}
 
Example 3
Source Project: MyBox   File: ImageManufacture.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean hasAlpha(BufferedImage source) {
    switch (source.getType()) {
        case BufferedImage.TYPE_3BYTE_BGR:
        case BufferedImage.TYPE_BYTE_BINARY:
        case BufferedImage.TYPE_BYTE_GRAY:
        case BufferedImage.TYPE_BYTE_INDEXED:
        case BufferedImage.TYPE_INT_BGR:
        case BufferedImage.TYPE_INT_RGB:
        case BufferedImage.TYPE_USHORT_555_RGB:
        case BufferedImage.TYPE_USHORT_565_RGB:
        case BufferedImage.TYPE_USHORT_GRAY:
            return false;
        default:
            if (source.getColorModel() != null) {
                return source.getColorModel().hasAlpha();
            } else {
                return true;
            }
    }
}
 
Example 4
/**
 * This determines the image type
 * 
 * @param namedStringParam
 * @return
 * @throws cfmRunTimeException
 */
private int getImageType(cfSession _session, String imageType) throws cfmRunTimeException {
	imageType = imageType.toUpperCase().trim();

	if (imageType.equals("3BYTE_BGR")) {
		return BufferedImage.TYPE_3BYTE_BGR;
	} else if (imageType.equals("4BYTE_ABGR")) {
		return BufferedImage.TYPE_4BYTE_ABGR;
	} else if (imageType.equals("4BYTE_ABGR_PRE")) {
		return BufferedImage.TYPE_4BYTE_ABGR_PRE;
	} else if (imageType.equals("BYTE_BINARY")) {
		return BufferedImage.TYPE_BYTE_BINARY;
	} else if (imageType.equals("BYTE_GRAY") || imageType.equals("GRAYSCALE")) {
		return BufferedImage.TYPE_BYTE_GRAY;
	} else if (imageType.equals("BYTE_INDEXED")) {
		return BufferedImage.TYPE_BYTE_INDEXED;
	} else if (imageType.equals("INT_ARGB") || imageType.equals("ARGB")) {
		return BufferedImage.TYPE_INT_ARGB;
	} else if (imageType.equals("INT_ARGB_PRE")) {
		return BufferedImage.TYPE_INT_ARGB_PRE;
	} else if (imageType.equals("INT_BGR")) {
		return BufferedImage.TYPE_INT_BGR;
	} else if (imageType.equals("INT_RGB") || imageType.equals("RGB")) {
		return BufferedImage.TYPE_INT_RGB;
	} else if (imageType.equals("USHORT_555_RGB")) {
		return BufferedImage.TYPE_USHORT_555_RGB;
	} else if (imageType.equals("USHORT_565_RGB")) {
		return BufferedImage.TYPE_USHORT_565_RGB;
	} else if (imageType.equals("USHORT_GRAY")) {
		return BufferedImage.TYPE_USHORT_GRAY;
	} else {
		throwException(_session, "invalid type specified: " + imageType);
	}

	return 0;
}
 
Example 5
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 6
private boolean canEncodeImage(String compression,
                               ImageTypeSpecifier imgType, int rawType)
{
    int biType = imgType.getBufferedImageType();
    if ((!compression.equals("BI_BITFIELDS")) &&
        ((rawType == BufferedImage.TYPE_USHORT_565_RGB) ||
         (rawType == TYPE_USHORT_565_BGR)))
    {
        return false;
    }

    int bpp = imgType.getColorModel().getPixelSize();
    if (compression.equals("BI_RLE4") && bpp != 4) {
        // only 4bpp images can be encoded as BI_RLE4
        return false;
    }
    if (compression.equals("BI_RLE8") && bpp != 8) {
        // only 8bpp images can be encoded as BI_RLE8
        return false;
    }

    if (compression.equals("BI_PNG") &&
        ((rawType == TYPE_USHORT_555_GRB) ||
         (rawType == TYPE_USHORT_555_BGR)))
    {
        return false;
    }

    return true;
}
 
Example 7
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 8
private boolean canEncodeImage(String compression,
                               ImageTypeSpecifier imgType, int rawType)
{
    int biType = imgType.getBufferedImageType();
    if ((!compression.equals("BI_BITFIELDS")) &&
        ((rawType == BufferedImage.TYPE_USHORT_565_RGB) ||
         (rawType == TYPE_USHORT_565_BGR)))
    {
        return false;
    }

    int bpp = imgType.getColorModel().getPixelSize();
    if (compression.equals("BI_RLE4") && bpp != 4) {
        // only 4bpp images can be encoded as BI_RLE4
        return false;
    }
    if (compression.equals("BI_RLE8") && bpp != 8) {
        // only 8bpp images can be encoded as BI_RLE8
        return false;
    }

    if (compression.equals("BI_PNG") &&
        ((rawType == TYPE_USHORT_555_GRB) ||
         (rawType == TYPE_USHORT_555_BGR)))
    {
        return false;
    }

    return true;
}
 
Example 9
private static 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 BufferedImage.TYPE_3BYTE_BGR:
            return "TYPE_3BYTE_BGR";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "TYPE_USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "TYPE_USHORT_565_RGB";
        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 TYPE_INT_555_GRB:
            return "TYPE_INT_555_GRB";
        case TYPE_3BYTE_RGB:
            return "TYPE_3BYTE_RGB";
        case TYPE_3BYTE_GRB:
            return "TYPE_3BYTE_GRB";
        default:
            throw new IllegalArgumentException("Unknown image type: " + t);
    }
}
 
Example 10
Source Project: MyBox   File: ImageValue.java    License: Apache License 2.0 5 votes vote down vote up
public static String imageType(int type) {
    switch (type) {
        case BufferedImage.TYPE_3BYTE_BGR:
            return "3BYTE_BGR";
        case BufferedImage.TYPE_4BYTE_ABGR:
            return "4BYTE_ABGR";
        case BufferedImage.TYPE_4BYTE_ABGR_PRE:
            return "4BYTE_ABGR_PRE";
        case BufferedImage.TYPE_BYTE_BINARY:
            return "BYTE_BINARY";
        case BufferedImage.TYPE_BYTE_GRAY:
            return "BYTE_GRAY";
        case BufferedImage.TYPE_BYTE_INDEXED:
            return "BYTE_INDEXED";
        case BufferedImage.TYPE_CUSTOM:
            return "CUSTOM";
        case BufferedImage.TYPE_INT_ARGB:
            return "INT_ARGB";
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return "INT_ARGB_PRE";
        case BufferedImage.TYPE_INT_BGR:
            return "INT_BGR";
        case BufferedImage.TYPE_INT_RGB:
            return "INT_RGB";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "USHORT_565_RGB";
    }
    return type + "";
}
 
Example 11
private boolean canEncodeImage(String compression,
                               ImageTypeSpecifier imgType, int rawType)
{
    int biType = imgType.getBufferedImageType();
    if ((!compression.equals("BI_BITFIELDS")) &&
        ((rawType == BufferedImage.TYPE_USHORT_565_RGB) ||
         (rawType == TYPE_USHORT_565_BGR)))
    {
        return false;
    }

    int bpp = imgType.getColorModel().getPixelSize();
    if (compression.equals("BI_RLE4") && bpp != 4) {
        // only 4bpp images can be encoded as BI_RLE4
        return false;
    }
    if (compression.equals("BI_RLE8") && bpp != 8) {
        // only 8bpp images can be encoded as BI_RLE8
        return false;
    }

    if (compression.equals("BI_PNG") &&
        ((rawType == TYPE_USHORT_555_GRB) ||
         (rawType == TYPE_USHORT_555_BGR)))
    {
        return false;
    }

    return true;
}
 
Example 12
Source Project: hottub   File: PixelTests.java    License: GNU General Public License v2.0 4 votes vote down vote up
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 13
private static String typeOf (int type)
{
    switch (type) {
    case BufferedImage.TYPE_CUSTOM:
        return "TYPE_CUSTOM";

    case BufferedImage.TYPE_INT_RGB:
        return "TYPE_INT_RGB";

    case BufferedImage.TYPE_INT_ARGB:
        return "TYPE_INT_ARGB";

    case BufferedImage.TYPE_INT_ARGB_PRE:
        return "TYPE_INT_ARGB_PRE";

    case BufferedImage.TYPE_INT_BGR:
        return "TYPE_INT_BGR";

    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_USHORT_565_RGB:
        return "TYPE_USHORT_565_RGB";

    case BufferedImage.TYPE_USHORT_555_RGB:
        return "TYPE_USHORT_555_RGB";

    case BufferedImage.TYPE_BYTE_GRAY:
        return "TYPE_BYTE_GRAY";

    case BufferedImage.TYPE_USHORT_GRAY:
        return "TYPE_USHORT_GRAY";

    case BufferedImage.TYPE_BYTE_BINARY:
        return "TYPE_BYTE_BINARY";

    case BufferedImage.TYPE_BYTE_INDEXED:
        return "TYPE_BYTE_INDEXED";

    default:
        return "?";
    }
}
 
Example 14
Source Project: diozero   File: SSD1331.java    License: MIT License 4 votes vote down vote up
public SSD1331(int controller, int chipSelect, DigitalOutputDevice dcPin, DigitalOutputDevice resetPin) {
	super(controller, chipSelect, dcPin, resetPin, WIDTH, HEIGHT, BufferedImage.TYPE_USHORT_565_RGB);
}
 
Example 15
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 16
protected int getPreferredCompressionType(ImageTypeSpecifier imageType) {
    if (imageType.getBufferedImageType() == BufferedImage.TYPE_USHORT_565_RGB) {
        return  BI_BITFIELDS;
    }
    return BI_RGB;
}
 
Example 17
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
Source Project: Bytecoder   File: BMPImageWriter.java    License: Apache License 2.0 4 votes vote down vote up
protected int getPreferredCompressionType(ImageTypeSpecifier imageType) {
    if (imageType.getBufferedImageType() == BufferedImage.TYPE_USHORT_565_RGB) {
        return  BI_BITFIELDS;
    }
    return BI_RGB;
}
 
Example 19
protected int getPreferredCompressionType(ImageTypeSpecifier imageType) {
    if (imageType.getBufferedImageType() == BufferedImage.TYPE_USHORT_565_RGB) {
        return  BI_BITFIELDS;
    }
    return BI_RGB;
}
 
Example 20
Source Project: diozero   File: SSD1351.java    License: MIT License 4 votes vote down vote up
public SSD1351(int controller, int chipSelect, DigitalOutputDevice dcPin, DigitalOutputDevice resetPin) {
	// Limit to 5-6-5 image type for now (65k colours)
	super(controller, chipSelect, dcPin, resetPin, WIDTH, HEIGHT, BufferedImage.TYPE_USHORT_565_RGB);
}