public static PixelRectangle convert( final PixelRectangle src, final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented, final boolean destIsDirect) { final int width = src.getSize().getWidth(); final int height = src.getSize().getHeight(); final int bpp = destFmt.comp.bytesPerPixel(); final int destStride; if (0 != ddestStride) { destStride = ddestStride; } else { destStride = bpp * width; } final int capacity = destStride * height; final ByteBuffer destBB = destIsDirect ? Buffers.newDirectByteBuffer(capacity) : ByteBuffer.allocate(capacity).order(src.getPixels().order()); convert(src, destBB, destFmt, isGLOriented, destStride); return new PixelRectangle.GenericPixelRect( destFmt, src.getSize(), destStride, isGLOriented, destBB); }
/** * @param src * @param dst_bb {@link ByteBuffer} sink * @param dst_fmt destination {@link PixelFormat} * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, * <i>origin at bottom left</i>, otherwise <i>origin at top left</i>. * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line * to the next. Must be >= {@link PixelFormat.Composition#bytesPerPixel() * dst_fmt.comp.bytesPerPixel()} * width or {@code zero} for default stride. * @throws IllegalStateException * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid */ public static void convert( final PixelRectangle src, final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, final int dst_lineStride) throws IllegalStateException { convert( src.getSize().getWidth(), src.getSize().getHeight(), src.getPixels(), src.getPixelformat(), src.isGLOriented(), src.getStride(), dst_bb, dst_fmt, dst_glOriented, dst_lineStride); }