// if( err != EdsError.EDS_ERR_OK ){
// System.err.println( "Failed to download live view image, focus point wasn't read (error "+ err.value() + ": "+ err.name() + " - " + err.description() + ")" );
// return null;
// }
final NativeLongByReference length = new NativeLongByReference();
err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetLength( streamRef.getValue(), length ) );
if ( err != EdsError.EDS_ERR_OK ) {
System.err.println( "Failed to download live view image, failed to read stream length (error " +
err.value() +
": " +
err.name() +
" - " +
err.description() + ")" );
CanonUtils.release( imageRef, streamRef );
return null;
}
final PointerByReference ref = new PointerByReference();
err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetPointer( streamRef.getValue(), ref ) );
if ( err != EdsError.EDS_ERR_OK ) {
System.err.println( "Failed to download live view image, failed to get reference to image in memory (error " +
err.value() +
": " +
err.name() +
" - " +
err.description() + ")" );
CanonUtils.release( imageRef, streamRef );
return null;
}
final byte[] data = ref.getValue().getByteArray( 0, length.getValue().intValue() );
try {
final BufferedImage img = ImageIO.read( new ByteArrayInputStream( data ) );
return img;
}
catch ( final IOException e ) {