当前位置: 首页>>代码示例>>Java>>正文


Java BufferedImage.TYPE_USHORT_565_RGB属性代码示例

本文整理汇总了Java中java.awt.image.BufferedImage.TYPE_USHORT_565_RGB属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.TYPE_USHORT_565_RGB属性的具体用法?Java BufferedImage.TYPE_USHORT_565_RGB怎么用?Java BufferedImage.TYPE_USHORT_565_RGB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.TYPE_USHORT_565_RGB属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

@Override
public void run() {
    BufferedImage bufferedImage = new BufferedImage(8,8,BufferedImage.TYPE_USHORT_565_RGB);

    while (!stop) {

        LocalTime now = LocalTime.now(clock);

        drawTime(bufferedImage, now);

        try {
            senseHat.fadeTo(bufferedImage, Duration.ofMillis(500));
        } catch (IOException e) {
            log.error(e.getLocalizedMessage(), e);
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:larsgrefer,项目名称:java-sense-hat,代码行数:18,代码来源:Clock.java

示例2: getImageTypeName

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";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ColConvTest.java

示例3: main

public static void main(String[] args) {
    int biType = BufferedImage.TYPE_USHORT_565_RGB;
    ImageTypeSpecifier type =
        ImageTypeSpecifier.createFromBufferedImageType(biType);

    int b0 = type.getBitsPerBand(0);
    int b1 = type.getBitsPerBand(1);
    int b2 = type.getBitsPerBand(2);

    if (b0 != 5 || b1 != 6 || b2 != 5) {
        throw new RuntimeException("Got incorrect bits per band value!");
    }

    boolean gotIAE = false;
    try {
        int b3 = type.getBitsPerBand(3);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }
    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException for band == 3!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ImageTypeSpecifierBitsPerBand.java

示例4: getImageTypeName

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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:BMPSubsamplingTest.java

示例5: readImageFromStream

public static BufferedImage readImageFromStream(ByteArrayInputStream is, int width, int height, PixelFormat pixelFormat) throws Exception{
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_USHORT_565_RGB);
    int ay = 0;
    while(ay < height){
        int ax = 0;
        while(ax < width){
            decodeTile(8, 8, ax, ay, img, is, pixelFormat);
            ax += 8;
        }
        ay += 8;
    }
    return img;
}
 
开发者ID:Ptrk25,项目名称:CDN-FX-2.2,代码行数:13,代码来源:IconImageUtils.java

示例6: canEncodeImage

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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:BMPSubsamplingTest.java

示例7: getImage

public BufferedImage getImage() throws IOException {
    BufferedImage image = new BufferedImage(8, 8, BufferedImage.TYPE_USHORT_565_RGB);

    short[] data = getDisplayData();
    image.getRaster().setDataElements(0, 0, 8, 8, data);

    return image;
}
 
开发者ID:larsgrefer,项目名称:java-sense-hat,代码行数:8,代码来源:SenseHat.java

示例8: setImage

public void setImage(BufferedImage image) throws IOException {
    if (image.getType() == BufferedImage.TYPE_USHORT_565_RGB) {

        short[] data = (short[]) image.getRaster().getDataElements(0, 0, 8, 8, new short[64]);
        setDisplayData(data);

    } else {
        BufferedImage convertedImg = convertImage(image);

        setImage(convertedImg);
    }
}
 
开发者ID:larsgrefer,项目名称:java-sense-hat,代码行数:12,代码来源:SenseHat.java

示例9: main

public static void main(String[] args) throws IOException {
    // buffered image types listed below can be saved as BI_BITFIELDS BMP
    int[] types = {BufferedImage.TYPE_3BYTE_BGR,
                   BufferedImage.TYPE_USHORT_555_RGB,
                   BufferedImage.TYPE_USHORT_565_RGB,
                   BufferedImage.TYPE_BYTE_GRAY,
                   BufferedImage.TYPE_BYTE_BINARY,
                   BufferedImage.TYPE_BYTE_INDEXED,
                   BufferedImage.TYPE_INT_BGR,
                   BufferedImage.TYPE_INT_RGB};

    for (int i = 0; i < types.length; i++) {
        System.out.println("Test image " + types[i]);
        TestCompressionBI_BITFIELDS t = new TestCompressionBI_BITFIELDS();

        BufferedImage src =
            t.createTestImage(types[i]);
        System.out.println("Image for test: " + src);
        System.out.println("SampleModel: " + src.getSampleModel());

        BufferedImage dst = null;
        try {
            dst = t.writeAndRead(src);
        } catch (IOException e) {
            e.printStackTrace(System.out);
        }


        t.compareImages(src, dst);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestCompressionBI_BITFIELDS.java

示例10: getImageTypeName

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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:NoExtraBytesTest.java

示例11: doTest

private void doTest() {
    BufferedImage src = createTestImage(type);
    System.out.println("Sample model is " + src.getSampleModel());

    BufferedImage dst = doModification(src);

    Object dstPixel = dst.getRaster().getDataElements(width/2, height/2, null);
    Object srcPixel = src.getRaster().getDataElements(width/2, height/2, null);

    if (src.getType() == BufferedImage.TYPE_USHORT_555_RGB ||
        src.getType() == BufferedImage.TYPE_USHORT_565_RGB ) {

        Color cmpColor = new Color(dst.getColorModel().getRed(dstPixel),
                                   dst.getColorModel().getGreen(dstPixel),
                                   dst.getColorModel().getBlue(dstPixel));
        BufferedImage cmp = createTestImage(src.getType(), cmpColor);

        Object cmpPixel = cmp.getRaster().getDataElements(width/2, height/2, null);

        dst = cmp;
        dstPixel = cmpPixel;
    }

    if ( (src.getColorModel().getRed(srcPixel) != dst.getColorModel().getRed(dstPixel)) ||
         (src.getColorModel().getGreen(srcPixel) != dst.getColorModel().getGreen(dstPixel)) ||
         (src.getColorModel().getBlue(srcPixel) != dst.getColorModel().getBlue(dstPixel)) ||
         (src.getColorModel().getAlpha(srcPixel) != dst.getColorModel().getAlpha(dstPixel)) ) {

        showPixel(src, width/2, height/2);
        showPixel(dst, width/2, height/2);

        showRes(dst, src);
        throw new RuntimeException(
            "Colors are different: " +
            Integer.toHexString(src.getColorModel().getRGB(srcPixel)) + " and " +
            Integer.toHexString(dst.getColorModel().getRGB(dstPixel)));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:WritingColorChangeTest.java

示例12: init

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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:PixelTests.java

示例13: getPreferredCompressionType

protected int getPreferredCompressionType(ImageTypeSpecifier imageType) {
    if (imageType.getBufferedImageType() == BufferedImage.TYPE_USHORT_565_RGB) {
        return  BI_BITFIELDS;
    }
    return BI_RGB;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:BMPImageWriter.java

示例14: displayText

public void displayText(String text) throws IOException {
    BufferedImage image = new BufferedImage(8, 8, BufferedImage.TYPE_USHORT_565_RGB);

    Graphics2D graphics = image.createGraphics();

    if (big) {
        text = text.toUpperCase();
    }

    Font sansSerif = new Font("SansSerif", Font.PLAIN, big ? 10 : 8);
    graphics.setFont(sansSerif);
    int i = graphics.getFontMetrics().stringWidth(text) - 8;
    if (i <= 0) {
        i = 1;
    }

    long durationInMillis = duration.toMillis();

    for (int j = 0; j <= i; j++) {
        long start = System.currentTimeMillis();
        graphics.setColor(background);
        graphics.setPaint(background);
        graphics.fillRect(0, 0, 8, 8);

        graphics.setColor(foreground);
        graphics.setPaint(foreground);
        graphics.drawString(text, -j, big ? 8 : 7);
        senseHat.fadeTo(image, duration.dividedBy(2));

        long timeToSleep = durationInMillis - (System.currentTimeMillis() - start);
        if(timeToSleep > 0) {
            try {
                Thread.sleep(timeToSleep);
            } catch (InterruptedException e) {
                log.error(e.getLocalizedMessage(), e);
            }
        }
    }

    graphics.dispose();
}
 
开发者ID:larsgrefer,项目名称:java-sense-hat,代码行数:41,代码来源:TextDisplay.java

示例15: convertImage

private BufferedImage convertImage(BufferedImage image) {
    BufferedImage convertedImg = new BufferedImage(8, 8, BufferedImage.TYPE_USHORT_565_RGB);
    Graphics graphics = convertedImg.getGraphics();
    graphics.drawImage(image, 0, 0, null);
    return convertedImg;
}
 
开发者ID:larsgrefer,项目名称:java-sense-hat,代码行数:6,代码来源:SenseHat.java


注:本文中的java.awt.image.BufferedImage.TYPE_USHORT_565_RGB属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。