java.awt.image.MultiPixelPackedSampleModel Java Examples

The following examples show how to use java.awt.image.MultiPixelPackedSampleModel. 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 check out the related API usage on the sidebar.
Example #1
Source File: ImageUtil.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #2
Source File: ImageUtil.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #3
Source File: ImageUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #4
Source File: ImageUtil.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #5
Source File: ImageUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #6
Source File: ICMColorDataTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void makeImage() {
    int scanLineBytes = WIDTH / PIXELS_IN_BYTE;
    if ((WIDTH & (PIXELS_IN_BYTE - 1)) != 0) {
        // Make sure all the pixels in a scan line fit
        scanLineBytes += 1;
    }

    byte[]     bits    = new byte[scanLineBytes * HEIGHT];
    DataBuffer dataBuf = new DataBufferByte(bits, bits.length, 0);
    SampleModel sampleModel = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                              WIDTH, HEIGHT, BITS_PER_PIXEL);
    WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuf, null);
    IndexColorModel indexModel = new IndexColorModel(2, 2, RED, GREEN, BLUE);
    BufferedImage bufImage = new BufferedImage(indexModel, raster,
                                               indexModel.isAlphaPremultiplied(), null);

    Graphics g = bufImage.getGraphics();
    g.drawRect(0, 0, WIDTH - 1, HEIGHT - 1);
    g.dispose();
}
 
Example #7
Source File: BinarizeDescriptor.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
/** Creates an BinarizeOpImage with a given ParameterBlock */

  public RenderedImage create(ParameterBlock paramBlock, 
			      RenderingHints renderingHints)
  {
    RenderedImage img = paramBlock.getRenderedSource(0);

    ImageLayout il = new ImageLayout(img);
    ColorModel cm = new IndexColorModel(1, 2, bwColors, bwColors, bwColors);
    SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
						     img.getWidth(),
						     img.getHeight(),
						     1);

    il.setColorModel(cm);
    il.setSampleModel(sm);

    return new BinarizeOpImage(paramBlock.getRenderedSource(0),
			       renderingHints,
			       il,
			       (Integer)paramBlock.getObjectParameter(0));
  }
 
Example #8
Source File: ImageUtil.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #9
Source File: ImageUtil.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static int getElementSize(SampleModel sm) {
    int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());

    if (sm instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sm;
        return mppsm.getSampleSize(0) * mppsm.getNumBands();
    } else if (sm instanceof ComponentSampleModel) {
        return sm.getNumBands() * elementSize;
    } else if (sm instanceof SinglePixelPackedSampleModel) {
        return elementSize;
    }

    return elementSize * sm.getNumBands();

}
 
Example #10
Source File: ICMColorDataTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void makeImage() {
    int scanLineBytes = WIDTH / PIXELS_IN_BYTE;
    if ((WIDTH & (PIXELS_IN_BYTE - 1)) != 0) {
        // Make sure all the pixels in a scan line fit
        scanLineBytes += 1;
    }

    byte[]     bits    = new byte[scanLineBytes * HEIGHT];
    DataBuffer dataBuf = new DataBufferByte(bits, bits.length, 0);
    SampleModel sampleModel = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                              WIDTH, HEIGHT, BITS_PER_PIXEL);
    WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuf, null);
    IndexColorModel indexModel = new IndexColorModel(2, 2, RED, GREEN, BLUE);
    BufferedImage bufImage = new BufferedImage(indexModel, raster,
                                               indexModel.isAlphaPremultiplied(), null);

    Graphics g = bufImage.getGraphics();
    g.drawRect(0, 0, WIDTH - 1, HEIGHT - 1);
    g.dispose();
}
 
Example #11
Source File: ICMColorDataTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void makeImage() {
    int scanLineBytes = WIDTH / PIXELS_IN_BYTE;
    if ((WIDTH & (PIXELS_IN_BYTE - 1)) != 0) {
        // Make sure all the pixels in a scan line fit
        scanLineBytes += 1;
    }

    byte[]     bits    = new byte[scanLineBytes * HEIGHT];
    DataBuffer dataBuf = new DataBufferByte(bits, bits.length, 0);
    SampleModel sampleModel = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                              WIDTH, HEIGHT, BITS_PER_PIXEL);
    WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuf, null);
    IndexColorModel indexModel = new IndexColorModel(2, 2, RED, GREEN, BLUE);
    BufferedImage bufImage = new BufferedImage(indexModel, raster,
                                               indexModel.isAlphaPremultiplied(), null);

    Graphics g = bufImage.getGraphics();
    g.drawRect(0, 0, WIDTH - 1, HEIGHT - 1);
    g.dispose();
}
 
Example #12
Source File: WBMPImageWriterSpi.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #13
Source File: GetSamplesTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();

    classes.add(ComponentSampleModel.class);
    classes.add(MultiPixelPackedSampleModel.class);
    classes.add(SinglePixelPackedSampleModel.class);
    classes.add(BandedSampleModel.class);
    classes.add(PixelInterleavedSampleModel.class);

    for (Class<? extends SampleModel> c : classes) {
        doTest(c);
    }
}
 
Example #14
Source File: WBMPImageWriterSpi.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #15
Source File: GetSamplesTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();

    classes.add(ComponentSampleModel.class);
    classes.add(MultiPixelPackedSampleModel.class);
    classes.add(SinglePixelPackedSampleModel.class);
    classes.add(BandedSampleModel.class);
    classes.add(PixelInterleavedSampleModel.class);

    for (Class<? extends SampleModel> c : classes) {
        doTest(c);
    }
}
 
Example #16
Source File: WBMPImageWriterSpi.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #17
Source File: WBMPImageWriterSpi.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #18
Source File: WBMPImageWriterSpi.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #19
Source File: WBMPImageWriterSpi.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #20
Source File: GetSamplesTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();

    classes.add(ComponentSampleModel.class);
    classes.add(MultiPixelPackedSampleModel.class);
    classes.add(SinglePixelPackedSampleModel.class);
    classes.add(BandedSampleModel.class);
    classes.add(PixelInterleavedSampleModel.class);

    for (Class<? extends SampleModel> c : classes) {
        doTest(c);
    }
}
 
Example #21
Source File: GetSamplesTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();

    classes.add(ComponentSampleModel.class);
    classes.add(MultiPixelPackedSampleModel.class);
    classes.add(SinglePixelPackedSampleModel.class);
    classes.add(BandedSampleModel.class);
    classes.add(PixelInterleavedSampleModel.class);

    for (Class<? extends SampleModel> c : classes) {
        doTest(c);
    }
}
 
Example #22
Source File: WBMPImageWriterSpi.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #23
Source File: WBMPImageWriterSpi.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #24
Source File: WBMPImageWriterSpi.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #25
Source File: WBMPImageWriterSpi.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #26
Source File: GetSamplesTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();

    classes.add(ComponentSampleModel.class);
    classes.add(MultiPixelPackedSampleModel.class);
    classes.add(SinglePixelPackedSampleModel.class);
    classes.add(BandedSampleModel.class);
    classes.add(PixelInterleavedSampleModel.class);

    for (Class<? extends SampleModel> c : classes) {
        doTest(c);
    }
}
 
Example #27
Source File: WBMPImageWriterSpi.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #28
Source File: WBMPImageWriterSpi.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #29
Source File: WBMPImageWriterSpi.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
 
Example #30
Source File: WBMPImageWriterSpi.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}