1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| function TTwainSource.SetImagelayoutFrame(const fLeft, fTop, fRight,
fBottom: double): TCapabilityRet;
var ImageLayout: TW_IMAGELAYOUT;
begin
if not Loaded then
begin
Result := crInvalidState; {In case the source is not loaded}
exit;
end;
fillchar({%H-}ImageLayout,sizeof(TW_IMAGELAYOUT),0);
with ImageLayout.Frame do
begin
Left:=FloatToFIX32(fLeft);
Top:=FloatToFIX32(fTop);
Right:=FloatToFIX32(fRight);
Bottom:=FloatToFIX32(fBottom);
end;
{Call method and store return}
Result := ResultToCapabilityRec(Owner.TwainProc(AppInfo, @Structure,
DG_IMAGE, DAT_IMAGELAYOUT, MSG_SET, @ImageLayout));
end;
{Converts from a result to a TCapabilityRec}
function TTwainSource.ResultToCapabilityRec(
const Value: TW_UINT16): TCapabilityRet;
begin
{Test result code to return}
case Value of
{Successull, copy handle and return a success value}
TWRC_SUCCESS: Result := crSuccess;
{Error, get more on the error, and return result}
{case} else
case GetReturnStatus() of
TWCC_CAPUNSUPPORTED: Result := crUnsupported;
TWCC_CAPBADOPERATION: Result := crBadOperation;
TWCC_CAPSEQERROR: Result := crDependencyError;
TWCC_LOWMEMORY: Result := crLowMemory;
TWCC_SEQERROR: Result := crInvalidState;
else Result := crBadOperation;
end {case GetReturnStatus of}
end {case};
end; |
Partager