本文整理汇总了Java中org.jcodec.common.model.ColorSpace.RGB属性的典型用法代码示例。如果您正苦于以下问题:Java ColorSpace.RGB属性的具体用法?Java ColorSpace.RGB怎么用?Java ColorSpace.RGB使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jcodec.common.model.ColorSpace
的用法示例。
在下文中一共展示了ColorSpace.RGB属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toColorArray
public static int[] toColorArray(Picture src){
if (src.getColor() != ColorSpace.RGB) {
Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB);
Picture rgb = Picture.create(src.getWidth(), src.getHeight(), ColorSpace.RGB, src.getCrop());
transform.transform(src, rgb);
src = rgb;
}
int[] _return = new int[src.getCroppedWidth() * src.getCroppedHeight()];
int[] data = src.getPlaneData(0);
for(int i = 0; i < _return.length; ++i){
_return[i] = ReadableRGBContainer.toIntColor(data[3*i + 2], data[3*i + 1], data[3*i]);
}
return _return;
}
示例2: encodeFrame
public ByteBuffer encodeFrame(Picture picture) {
if (picture.getColor() != ColorSpace.RGB)
throw new IllegalArgumentException("Only RGB image can be stored in PPM");
ByteBuffer buffer = ByteBuffer.allocate(picture.getWidth() * picture.getHeight() * 3 + 200);
buffer.put(JCodecUtil.asciiString("P6 " + picture.getWidth() + " " + picture.getHeight() + " 255\n"));
int[][] data = picture.getData();
for (int i = 0; i < picture.getWidth() * picture.getHeight() * 3; i += 3) {
buffer.put((byte) data[0][i + 2]);
buffer.put((byte) data[0][i + 1]);
buffer.put((byte) data[0][i]);
}
buffer.flip();
return buffer;
}
示例3: toBufferedImage
public static BufferedImage toBufferedImage(Picture src) {
if (src.getColor() != ColorSpace.RGB) {
Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB);
Picture rgb = Picture.create(src.getWidth(), src.getHeight(), ColorSpace.RGB, src.getCrop());
transform.transform(src, rgb);
src = rgb;
}
BufferedImage dst = new BufferedImage(src.getCroppedWidth(), src.getCroppedHeight(),
BufferedImage.TYPE_3BYTE_BGR);
if (src.getCrop() == null)
toBufferedImage(src, dst);
else
toBufferedImageCropped(src, dst);
return dst;
}