TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Re: Here is a sample of the code i hope is helps a little

Forums › TWAIN Classic › Making a scanning preview › Re: Here is a sample of the code i hope is helps a little

August 1, 2008 at 7:45 pm #24584
GaaraTheKasekage
Participant
  • Topics - 3
  • Replies - 9
  • Total Posts - 12

ALL THIS IS IN THE MAIN PROGRAM
=======================================================================================
I set the procedures to let the source loaded for setting triplets
……….

setvalues;	//<

Procedure where you set values in state before source getting enabled
Twain.Source[LoadedSource].TransferMode := Self.TransferMode;
Twain.Source[LoadedSource].EnableSource(ItemShowInterface.Checked, false);
while Twain.Source[LoadedSource].Enabled do
begin
// twain.Source[CurrentSource].SetICapUnits(tucentimeters);
Application.ProcessMessages;
end;

…..
here in setvalues;
i do something like this


setvaluefor('ICAP_SHADOW');
setvaluefor('ICAP_GAMMA');
if (tamapapel.Text='Personalizado...') and (modopreview=false) then
begin
SendCommandForm.TestResult(twain.Source[CurrentSource].SetImagelayoutFrame(fy1,fx1,fy2,fx2));
end;

==========================================================================================
THIS IS PART OF THE COMPONENT FROM DELPHITWAIN
==========================================================================================

function SetImagelayoutFrame(const fLeft,fTop,fRight,fBottom: double): TCapabilityRet;
---
//npeter: 2004.01.12
//sets the acquired area
function TTwainSource.SetImagelayoutFrame(const fLeft, fTop, fRight,fBottom: double): TCapabilityRet;
var ImageLayout: TW_IMAGELAYOUT;
fraccion:real;
begin
if not Loaded then
begin
Result := crInvalidState; {In case the source is not loaded}
exit;
end;

fillchar(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;

if any doubt about floattofix32


function FloatToFix32 (floater: extended): TW_FIX32;
var
fracpart : extended;
begin
//Obtain numerical part by truncating the float number
Result.Whole := trunc(floater);
//Obtain fracional part by subtracting float number by
//numerical part. Also we make sure the number is not
//negative by multipling by -1 if it is negative
fracpart := floater - result.Whole;
if fracpart < 0 then fracpart := fracpart * -1;
//Multiply by 10 until there is no fracional part any longer
while FracPart - trunc(FracPart) <> 0 do fracpart := fracpart * 10;
//Return fracional part
Result.Frac := trunc(fracpart);
end;

[/code]

The full code of delphiTwain for Borland Delphi is http://delphitwain.sourceforge.net/
any doubt or anything you want just tell me

Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • TWAIN for dental imaging integration
  • PDF/R For who and where?
  • Making searchable PDF with PDF/R
  • Backward compatibility with PDF/A and traditional PDF
  • could not open the twain source. Make sure there is a valid source for your sca
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in