public static void convert(Frame input , ImageBase output , boolean swapRgb, GrowQueue_I8 work) { if( work == null ) work = new GrowQueue_I8(); Buffer data = input.image[0]; if( !(data instanceof ByteBuffer) ) { return; } ByteBuffer bb = (ByteBuffer)data; output.reshape(input.imageWidth,input.imageHeight); if( output instanceof Planar ) { ((Planar)output).setNumberOfBands(input.imageChannels); ConvertByteBufferImage.from_3BU8_to_3PU8(bb,0,input.imageStride,(Planar)output,work); if( swapRgb ) { BGR_to_RGB((Planar)output); } } else if( output instanceof ImageGray ) { ConvertByteBufferImage.from_3BU8_to_U8(bb,0,input.imageStride,(GrayU8)output,work); } else if( output instanceof ImageInterleaved) { ConvertByteBufferImage.from_3BU8_to_3IU8(bb,0,input.imageStride,(InterleavedU8)output); } else { throw new IllegalArgumentException("Unsupported output type"); } }