package org.aohe.transfer;


import org.aohe.core.twain.Twain;
import org.aohe.core.twain.TwainSource;
import org.aohe.exceptions.TwainException;
import org.aohe.utils.TwainUtils;

public class TwainNativeTransfer extends TwainTransfer {

    private final byte[] imageHandle = new byte[8];

    public TwainNativeTransfer(TwainSource source) {
        super(source);
    }

    @Override
    public void initiate() throws TwainException {
        super.initiate();
        source.call(Twain.DG_IMAGE, Twain.DAT_IMAGENATIVEXFER, Twain.MSG_GET, imageHandle);
    }

    @Override
    public void finish() throws TwainException {
        int handle = TwainUtils.getINT32(imageHandle, 0);
        Twain.transferNativeImage(handle);
    }

}
