Java 类java.awt.image.MultiPixelPackedSampleModel 实例源码

项目:OpenJSharp    文件:ImageUtil.java   
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();

}
项目:jdk8u-jdk    文件:ImageUtil.java   
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();

}
项目:openjdk-jdk10    文件:ImageUtil.java   
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();

}
项目:openjdk9    文件:ImageUtil.java   
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();

}
项目:jdk8u_jdk    文件:ImageUtil.java   
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();

}
项目:lookaside_java-1.8.0-openjdk    文件:ImageUtil.java   
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();

}
项目:javify    文件:ImageTypeSpecifier.java   
/**
 * Create a grayscale image type specifier, given the number of
 * bits, data type and whether or not the data is signed.
 *
 * @param bits the number of bits used to specify a greyscale value
 * @param dataType a DataBuffer type constant
 * @param isSigned true if this type specifier should support
 * negative values, false otherwise
 *
 * @return a greyscal image type specifier
 *
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
                                                  boolean isSigned,
                                                  boolean isAlphaPremultiplied)
{
  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
                                                       0x0, 0xff),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
项目:javify    文件:DecodeRLE4.java   
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
    IndexColorModel palette = readPalette(in);
    skipToImage(in);

    Dimension d = infoHeader.getSize();
    int h = (int)d.getHeight();
    int w = (int)d.getWidth();

    byte[] data = uncompress(w, h, in);
    SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                     w, h, 4);

    DataBuffer db = new DataBufferByte(data, w*h, 0);
    WritableRaster raster = Raster.createWritableRaster(sm, db, null);

    return new BufferedImage(palette, raster, false, null);
}
项目:jvm-stm    文件:ImageTypeSpecifier.java   
/**
 * Create a grayscale image type specifier, given the number of
 * bits, data type and whether or not the data is signed.
 *
 * @param bits the number of bits used to specify a greyscale value
 * @param dataType a DataBuffer type constant
 * @param isSigned true if this type specifier should support
 * negative values, false otherwise
 *
 * @return a greyscal image type specifier
 *
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
                                                  boolean isSigned,
                                                  boolean isAlphaPremultiplied)
{
  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
                                                       0x0, 0xff),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
项目:jvm-stm    文件:DecodeRLE4.java   
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
IndexColorModel palette = readPalette(in);
skipToImage(in);

Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();

byte[] data = uncompress(w, h, in);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, 
                         w, h, 4);

DataBuffer db = new DataBufferByte(data, w*h, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);

return new BufferedImage(palette, raster, false, null);
   }
项目:infobip-open-jdk-8    文件:ImageUtil.java   
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();

}
项目:jdk8u-dev-jdk    文件:ImageUtil.java   
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();

}
项目:jdk7-jdk    文件:ImageUtil.java   
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();

}
项目:rastertheque    文件:TransposeCRIF.java   
/**
 * Creates a Tranpose operation.
 */
public RenderedImage create(ParameterBlock paramBlock,
                            RenderingHints renderHints) {
    // Get ImageLayout from renderHints if any.
    ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);


    RenderedImage source = paramBlock.getRenderedSource(0);

    EnumeratedParameter type =
        (EnumeratedParameter)paramBlock.getObjectParameter(0);

    SampleModel sm = source.getSampleModel();
    if ((sm instanceof MultiPixelPackedSampleModel) &&
        (sm.getSampleSize(0) == 1) &&
        (sm.getDataType() == DataBuffer.TYPE_BYTE || 
         sm.getDataType() == DataBuffer.TYPE_USHORT || 
         sm.getDataType() == DataBuffer.TYPE_INT)) {
        return new TransposeBinaryOpImage(source, renderHints, layout,
                                          type.getValue());
    } else {
        return new TransposeOpImage(source, renderHints, layout,
                                    type.getValue());
    }
}
项目:rastertheque    文件:ROI.java   
/**
    * Create a binary PlanarImage of the size/bounds specified by
    * the rectangle.
    */
   private static PlanarImage createBinaryImage(Rectangle r) {

if ((r.x == 0) && (r.y == 0)) {

    BufferedImage bi =
        new BufferedImage(r.width, r.height,
            BufferedImage.TYPE_BYTE_BINARY);

    return PlanarImage.wrapRenderedImage(bi);

} else {

    SampleModel sm =
    new MultiPixelPackedSampleModel(
        DataBuffer.TYPE_BYTE, r.width, r.height, 1);

    // Create a TiledImage into which to write.
    return new TiledImage(r.x, r.y, r.width, r.height, r.x, r.y,
            sm, PlanarImage.createColorModel(sm));
}
   }
项目:openjdk-source-code-learn    文件:ImageUtil.java   
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();

}
项目:OLD-OpenJDK8    文件:ImageUtil.java   
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();

}
项目:JamVM-PH    文件:ImageTypeSpecifier.java   
/**
 * Create a grayscale image type specifier, given the number of
 * bits, data type and whether or not the data is signed.
 *
 * @param bits the number of bits used to specify a greyscale value
 * @param dataType a DataBuffer type constant
 * @param isSigned true if this type specifier should support
 * negative values, false otherwise
 *
 * @return a greyscal image type specifier
 *
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
                                                  boolean isSigned,
                                                  boolean isAlphaPremultiplied)
{
  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
                                                       0x0, 0xff),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
项目:JamVM-PH    文件:DecodeRLE4.java   
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
IndexColorModel palette = readPalette(in);
skipToImage(in);

Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();

byte[] data = uncompress(w, h, in);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, 
                         w, h, 4);

DataBuffer db = new DataBufferByte(data, w*h, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);

return new BufferedImage(palette, raster, false, null);
   }
项目:openjdk-jdk7u-jdk    文件:ImageUtil.java   
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();

}
项目:classpath    文件:ImageTypeSpecifier.java   
/**
 * Create a grayscale image type specifier, given the number of
 * bits, data type and whether or not the data is signed.
 *
 * @param bits the number of bits used to specify a greyscale value
 * @param dataType a DataBuffer type constant
 * @param isSigned true if this type specifier should support
 * negative values, false otherwise
 *
 * @return a greyscal image type specifier
 *
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
                                                  boolean isSigned,
                                                  boolean isAlphaPremultiplied)
{
  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
                                                       0x0, 0xff),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
项目:classpath    文件:DecodeRLE4.java   
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
    IndexColorModel palette = readPalette(in);
    skipToImage(in);

    Dimension d = infoHeader.getSize();
    int h = (int)d.getHeight();
    int w = (int)d.getWidth();

    byte[] data = uncompress(w, h, in);
    SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                     w, h, 4);

    DataBuffer db = new DataBufferByte(data, w*h, 0);
    WritableRaster raster = Raster.createWritableRaster(sm, db, null);

    return new BufferedImage(palette, raster, false, null);
}
项目:openjdk-icedtea7    文件:ImageUtil.java   
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();

}
项目:scifio-jai-imageio    文件:ImageUtil.java   
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();

   }
项目:pdfxtk    文件:BinarizeDescriptor.java   
/** 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));
  }
项目:incubator-netbeans    文件:ImageBuilder.java   
@Override
public SampleModel convert(FieldAccessor fa, Instance instance) throws FieldAccessor.InvalidFieldException {
    int width = fa.getInt(instance, "width");          // NOI18N
    int height = fa.getInt(instance, "height");  // NOI18N
    int dataType = fa.getInt(instance, "dataType");   // NOI18N
    int scanlineStride = fa.getInt(instance, "scanlineStride");  // NOI18N
    int numberOfBits = fa.getInt(instance, "numberOfBits");  // NOI18N
    int dataBitOffset = fa.getInt(instance, "dataBitOffset");  // NOI18N
    return new MultiPixelPackedSampleModel(dataType, width, height, numberOfBits, scanlineStride, dataBitOffset);
}
项目:OpenJSharp    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:jdk8u-jdk    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:jdk8u-jdk    文件:GetSamplesTest.java   
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);
    }
}
项目:openjdk-jdk10    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:openjdk-jdk10    文件:GetSamplesTest.java   
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);
    }
}
项目:openjdk9    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:openjdk9    文件:GetSamplesTest.java   
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);
    }
}
项目:jdk8u_jdk    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:jdk8u_jdk    文件:GetSamplesTest.java   
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:WBMPImageWriterSpi.java   
public boolean canEncodeImage(ImageTypeSpecifier type) {
    SampleModel sm = type.getSampleModel();
    if (!(sm instanceof MultiPixelPackedSampleModel))
        return false;
    if (sm.getSampleSize(0) != 1)
        return false;

    return true;
}
项目:lookaside_java-1.8.0-openjdk    文件:GetSamplesTest.java   
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);
    }
}
项目:javify    文件:ImageTypeSpecifier.java   
/**
 * Return an image type specifier for an image that uses an indexed
 * colour model where each colour value has the specified number of
 * bits and type and where the colour tables are those given.
 *
 * @param redLUT the red index values
 * @param greenLUT the green index values
 * @param blueLUT the blue index values
 * @param alphaLUT the alpha index values
 * @param bits the number of bits per index value
 * @param dataType the type of each index value
 *
 * @return an indexed image type specifier
 *
 * @exception IllegalArgumentException if any of the colour arrays,
 * not including alphaLUT, is null
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createIndexed (byte[] redLUT,
                                                byte[] greenLUT,
                                                byte[] blueLUT,
                                                byte[] alphaLUT,
                                                int bits,
                                                int dataType)
{
  if (redLUT == null || greenLUT == null || blueLUT == null)
    throw new IllegalArgumentException ("null colour table");

  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new IndexColorModel (bits, redLUT.length,
                                                      redLUT, greenLUT, blueLUT,
                                                      alphaLUT),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
项目:javify    文件:DecodeRGB4.java   
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
    IndexColorModel palette = readPalette(in);
    skipToImage(in);

    Dimension d = infoHeader.getSize();
    int h = (int)d.getHeight();
    int w = (int)d.getWidth();
    int size = (w*h) >> 1;

    // Scanline padded to dword offsets
    int wbytes = (w + (w & 1)) >> 1;
    int scansize = ((wbytes & 3) != 0)? (wbytes + 4 - (wbytes&3)) : wbytes;

    byte[] data = new byte[wbytes*h];

    for(int y=h-1;y>=0;y--){
        byte[] scanline = new byte[scansize];
        if(in.read(scanline) != scansize)
            throw new IOException("Couldn't read image data.");

        for(int x=0;x<wbytes;x++)
            data[x + y*wbytes] = scanline[x];
    }
    SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                     w, h, 4);

    DataBuffer db = new DataBufferByte(data, w*h, 0);
    WritableRaster raster = Raster.createWritableRaster(sm, db, null);

    return new BufferedImage(palette, raster, false, null);
}
项目:jvm-stm    文件:ImageTypeSpecifier.java   
/**
 * Return an image type specifier for an image that uses an indexed
 * colour model where each colour value has the specified number of
 * bits and type and where the colour tables are those given.
 *
 * @param redLUT the red index values
 * @param greenLUT the green index values
 * @param blueLUT the blue index values
 * @param alphaLUT the alpha index values
 * @param bits the number of bits per index value
 * @param dataType the type of each index value
 *
 * @return an indexed image type specifier
 *
 * @exception IllegalArgumentException if any of the colour arrays,
 * not including alphaLUT, is null
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createIndexed (byte[] redLUT,
                  byte[] greenLUT,
                  byte[] blueLUT,
                  byte[] alphaLUT,
                  int bits,
                  int dataType)
{
  if (redLUT == null || greenLUT == null || blueLUT == null)
    throw new IllegalArgumentException ("null colour table");

  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new IndexColorModel (bits, redLUT.length,
                                                      redLUT, greenLUT, blueLUT,
                                                      alphaLUT),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}