Forum Replies Created
- AuthorPosts
I can T do anything!!!
Can be this part of the problem maybe is not the triplet at all maybe it is the bmp watch this code:
function TTwainSource.PrepareMemXfer(var BitmapHandle: HBitmap; var PixelType: TW_INT16): TW_UINT16;
const
PixelColor: Array[TTwainPixelFlavor] of Array[0..1] of Byte =
((0, $FF), ($FF, 00), (0, $FF));
var
Handle: HGlobal;
Info: TW_IMAGEINFO;
Setup: TW_SETUPMEMXFER;
structsize, index, Size, Blocks: Integer;
XRes, YRes: Extended;
Pal : TW_PALETTE8;
vUnit : TTwainUnit;
vUnits: TTwainUnitSet;
Dib : pBitmapInfo;
PixelFlavor: TTwainPixelFlavor;
PixelFlavors: TTwainPixelFlavorSet;
DC: HDC;
Data : Pointer;
begin
{First of all, get information on the image being acquired}
Result := Owner.TwainProc(AppInfo, @Structure, DG_IMAGE, DAT_IMAGEINFO,MSG_GET, @Info);
if Result <> TWRC_SUCCESS then exit;
{Calculate image size}
with Info do
size := ((((ImageWidth * BitsPerPixel + 31) div 32)*4) * info.ImageLength);
{Obtain image buffer transference sizes}
Owner.TwainProc(AppInfo, @Structure, DG_CONTROL, DAT_SETUPMEMXFER, MSG_GET, @Setup);
blocks := (size div Integer(setup.Preferred));
size := (blocks + 1) * Integer(setup.Preferred);
{Prepare new bitmap}
structsize := size + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
Handle := GlobalAlloc(GHND, StructSize);
Dib := GlobalLock(Handle);
Fillchar(Dib^, structsize, #0);
{Fill image information}
Dib^.bmiHeader.biSize := sizeof(BITMAPINFOHEADER);
Dib^.bmiHeader.biWidth := info.ImageWidth;
Dib^.bmiHeader.biHeight := info.ImageLength;
{Only 1 plane supported}
Dib^.bmiHeader.biPlanes := 1;
Dib^.bmiHeader.biBitCount := info.BitsPerPixel;
{No compression}
Dib^.bmiHeader.biCompression := BI_RGB;
Dib^.bmiHeader.biSizeImage := Size;
{Adjust units}
XRes := Fix32ToFloat(Info.XResolution);
YRes := Fix32ToFloat(Info.YResolution);
GetICapUnits(vUnit, vUnits);
case vUnit of
tuInches: begin
Dib^.bmiHeader.biXPelsPerMeter := Trunc((XRes*2.54)*100);
Dib^.bmiHeader.biYPelsPerMeter := Trunc((YRes*2.54)*100);
end;
tuCentimeters: begin
Dib^.bmiHeader.biXPelsPerMeter := Trunc(XRes*100);
Dib^.bmiHeader.biYPelsPerMeter := Trunc(YRes*100);
end
else begin
Dib^.bmiHeader.biXPelsPerMeter := 0;
Dib^.bmiHeader.biYPelsPerMeter := 0;
end
end {case vUnits of};
{Now it should setup the palette to be used by the image}
{by either building a definied palette or retrieving the}
{image's one}
Did u do something like this?
when i set in MSG_GET
I hit Send and then does this
returned:TWRC_SUCCESS
Frame.Left=0.000
Frame.Top=0.000
Frame.Right=0.000
Frame.Bottom=0.000
DocumentNumber=1
PageNumber=1
FrameNumber=1I send DG_IMAGE,DAT_IMAGELAYOUT,MSG_SET
I tried to put these values
Frame.Left=1.0897
Frame.Top=1.266
Frame.Right=2.106
Frame.Bottom=2.496
DocumentNumber=
PageNumber=
FrameNumber=I hit Send and then does this
returned:TWRC_SUCCESS
Frame.Left=0.000
Frame.Top=0.000
Frame.Right=0.000
Frame.Bottom=0.000
DocumentNumber=1
PageNumber=1
FrameNumber=1and when enabled appeared the UI and atry to digitalize and does nothing
Start of Twister TWAIN Analysis
Analysis Started: 2008.08.04 at 08:24:27
Twister Version: 1.05.004— TW_IDENTITY block —
Product Name: Xerox WorkCentre PE220 Series
Product Family: Xerox WorkCentre PE220 Series
Manufacturer: Xerox
Software Version: 2.1 (“2.01.57”)
TWAIN Protocol Version: 1.9— DataSource File Version Info —
File: C:WINDOWSTwain_32XeroxWCPE220OEMDS.DS
File Timestamp: 2008.01.31 19:45:10
** unable to get version info from C:WINDOWSTwain_32XeroxWCPE220OEMDS.DS **Section 1. Capabilities
If a capability does not appear in the following list, then the device
reported it as unsupported in conformance with the TWAIN standard.CAP_XFERCOUNT:
GET………….int16 -1
GETCURRENT……int16 -1
GETDEFAULT……int16 -1ICAP_COMPRESSION:
GET………….uint16 TWCP_NONE
GETCURRENT……uint16 TWCP_NONE
GETDEFAULT……uint16 TWCP_NONE
SET………….TWCP_NONE okICAP_PIXELTYPE:
GET………….uint16 ENUM{ TWPT_BW, TWPT_GRAY, TWPT_RGB, TWPT_PALETTE }
Current: TWPT_RGB, Default: TWPT_RGB
GETCURRENT……uint16 TWPT_RGB
GETDEFAULT……uint16 TWPT_RGB
SET………….TWPT_BW ok
SET………….TWPT_GRAY ok
SET………….TWPT_RGB ok
SET………….TWPT_PALETTE okICAP_UNITS:
GET………….uint16 TWUN_INCHES
GETCURRENT……uint16 TWUN_INCHES
GETDEFAULT……uint16 TWUN_INCHES
SET………….TWUN_INCHES okICAP_XFERMECH:
GET………….uint16 ENUM{ TWSX_NATIVE, TWSX_FILE, TWSX_MEMORY }
Current: TWSX_NATIVE, Default: TWSX_NATIVE
GETCURRENT……uint16 TWSX_NATIVE
GETDEFAULT……uint16 TWSX_NATIVE
SET………….TWSX_NATIVE ok
SET………….TWSX_FILE ok
SET………….TWSX_MEMORY okCAP_FEEDERENABLED:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUE
SET(FALSE)……ok
SET(TRUE)…….okCAP_FEEDERLOADED:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool FALSECAP_SUPPORTEDCAPS:
GET………….uint16 ARRAY[ CAP_XFERCOUNT, CAP_UICONTROLLABLE,
CAP_DEVICEONLINE, ICAP_PHYSICALHEIGHT, ICAP_PHYSICALWIDTH,
ICAP_COMPRESSION, ICAP_PLANARCHUNKY, ICAP_PIXELFLAVOR,
ICAP_BITORDER, ICAP_XFERMECH, ICAP_UNITS,
ICAP_XRESOLUTION, ICAP_YRESOLUTION, ICAP_PIXELTYPE,
ICAP_BITDEPTH, CAP_INDICATORS, ICAP_IMAGEFILEFORMAT,
ICAP_SUPPORTEDSIZES, ICAP_MINIMUMHEIGHT,
ICAP_MINIMUMWIDTH, ICAP_XNATIVERESOLUTION,
ICAP_YNATIVERESOLUTION, ICAP_XSCALING, ICAP_YSCALING,
ICAP_BRIGHTNESS, ICAP_CONTRAST, ICAP_HIGHLIGHT,
ICAP_SHADOW, ICAP_ROTATION, ICAP_GAMMA, CAP_FEEDERENABLED,
CAP_PAPERDETECTABLE, CAP_AUTOFEED, CAP_FEEDERLOADED,
CAP_CLEARPAGE, CAP_DUPLEX, CAP_DUPLEXENABLED,
ICAP_FLIPROTATION, ICAP_TILES, CAP_FEEDERALIGNMENT,
CAP_FEEDERORDER, CAP_SUPPORTEDCAPS ]
GETCURRENT……ditto
GETDEFAULT……dittoCAP_AUTOFEED:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUE
SET(FALSE)…..?failed
SET(TRUE)…….okCAP_CLEARPAGE:
GET………….bool FALSE
GETCURRENT……bool FALSE
GETDEFAULT……bool FALSE
SET………….not tested due to side effects.CAP_INDICATORS:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUE
SET(FALSE)……ok
SET(TRUE)…….okCAP_PAPERDETECTABLE:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool FALSECAP_UICONTROLLABLE:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUECAP_DEVICEONLINE:
GET………….bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUECAP_DUPLEX:
GET………….uint16 TWDX_NONE
GETCURRENT……uint16 TWDX_NONE
GETDEFAULT……uint16 TWDX_NONECAP_DUPLEXENABLED:
GET…………*not supported.CAP_FEEDERALIGNMENT:
GET………….uint16 TWFA_RIGHT
GETCURRENT……uint16 TWFA_RIGHT
GETDEFAULT……uint16 TWFA_RIGHT
SET…………?TWFA_RIGHT failedCAP_FEEDERORDER:
GET………….uint16 0
GETCURRENT……uint16 0
GETDEFAULT……uint16 0
SET…………?0 failedICAP_BRIGHTNESS:
GET………….fix32 From -1000 To 1000 Step 10, Current: 0, Default: 0
GETCURRENT……fix32 0
GETDEFAULT……fix32 0
SET………….0 ok
SET………….-1000 ok
SET………….-500 ok
SET………….500 ok
SET………….1000 okICAP_CONTRAST:
GET………….fix32 From -1000 To 1000 Step 10, Current: 0, Default: 0
GETCURRENT……fix32 0
GETDEFAULT……fix32 0
SET………….0 ok
SET………….-1000 ok
SET………….-500 ok
SET………….500 ok
SET………….1000 okICAP_GAMMA:
GET………….fix32 1
GETCURRENT……fix32 1
GETDEFAULT……fix32 1
SET………….1 okICAP_HIGHLIGHT:
GET………….fix32 From 1 To 255 Step 1, Current: 255, Default: 255
GETCURRENT……fix32 255
GETDEFAULT……fix32 255
SET………….255 ok
SET………….1 ok
SET………….64 ok
SET………….128 ok
SET………….191 okICAP_IMAGEFILEFORMAT:
GET………….uint16 TWFF_BMP
GETCURRENT……uint16 TWFF_BMP
GETDEFAULT……uint16 TWFF_BMP
SET………….TWFF_BMP okICAP_PHYSICALWIDTH:
GET………….fix32 8.5
GETCURRENT……fix32 8.5
GETDEFAULT……fix32 8.5ICAP_PHYSICALHEIGHT:
GET………….fix32 14
GETCURRENT……fix32 14
GETDEFAULT……fix32 14ICAP_SHADOW:
GET…………*fix32 From 0 To 254 Step 1, Current: 0, Default: 0
GETCURRENT……fix32 0
GETDEFAULT……fix32 0
SET………….0 ok
SET………….63 ok
SET………….127 ok
SET………….190 ok
SET………….254 okICAP_XNATIVERESOLUTION:
GET………….fix32 600ICAP_YNATIVERESOLUTION:
GET………….fix32 600ICAP_XRESOLUTION:
GET………….fix32 ENUM{ 75, 100, 150, 200, 300, 600, 1200, 2400, 4800
} Current: 300, Default: 300
GETCURRENT……fix32 300
GETDEFAULT……fix32 300
SET………….300 ok
SET………….75 ok
SET………….150 ok
SET………….1200 ok
SET………….4800 okICAP_YRESOLUTION:
GET………….fix32 ENUM{ 75, 100, 150, 200, 300, 600, 1200, 2400, 4800
} Current: 300, Default: 300
GETCURRENT……fix32 300
GETDEFAULT……fix32 300
SET………….300 ok
SET………….75 ok
SET………….150 ok
SET………….1200 ok
SET………….4800 okICAP_TILES:
GET…………*bool TRUE
GETCURRENT……bool TRUE
GETDEFAULT……bool TRUE
SET(FALSE)……ok
SET(TRUE)…….okICAP_BITORDER:
GET………….uint16 TWBO_MSBFIRST
GETCURRENT……uint16 TWBO_MSBFIRST
GETDEFAULT……uint16 TWBO_MSBFIRST
SET………….TWBO_MSBFIRST okICAP_PIXELFLAVOR:
GET………….uint16 TWPF_CHOCOLATE
GETCURRENT……uint16 TWPF_CHOCOLATE
GETDEFAULT……uint16 TWPF_CHOCOLATE
SET………….TWPF_CHOCOLATE okICAP_PLANARCHUNKY:
GET………….uint16 TWPC_CHUNKY
GETCURRENT……uint16 TWPC_CHUNKY
GETDEFAULT……uint16 TWPC_CHUNKY
SET………….TWPC_CHUNKY okICAP_ROTATION:
GET………….fix32 ENUM{ 0, 90, 180, 270 } Current: 0, Default: 0
GETCURRENT……fix32 0
GETDEFAULT……fix32 0
SET………….0 ok
SET………….90 ok
SET………….180 ok
SET………….270 okICAP_SUPPORTEDSIZES:
GET………….uint16 ENUM{ TWSS_USLETTER, TWSS_USLEGAL,
TWSS_USEXECUTIVE, TWSS_USSTATEMENT,
TWSS_A4(TWSS_A4LETTER), TWSS_A5, TWSS_ISOB5,
TWSS_B5LETTER/TWSS_JISB5, TWSS_JISB6, TWSS_C5 } Current:
TWSS_A4(TWSS_A4LETTER), Default: TWSS_A4(TWSS_A4LETTER)
GETCURRENT……uint16 TWSS_A4(TWSS_A4LETTER)
GETDEFAULT……ditto
SET………….TWSS_USLETTER ok
SET………….TWSS_USLEGAL ok
SET………….TWSS_USEXECUTIVE ok
SET………….TWSS_USSTATEMENT ok
SET………….TWSS_A5 ok
SET………….TWSS_ISOB5 ok
SET………….TWSS_B5LETTER/TWSS_JISB5 ok
SET………….TWSS_C5 okICAP_XSCALING:
GET………….fix32 From 0.25 To 4 Step 0.009995, Current: 1, Default: 1
GETCURRENT……fix32 1
GETDEFAULT……fix32 1
SET………….0.25 ok
SET………….1.179489 ok
SET………….2.118973 ok
SET………….3.058456 ok
SET………….3.99794 okICAP_YSCALING:
GET………….fix32 From 0.25 To 4 Step 0.009995, Current: 1, Default: 1
GETCURRENT……fix32 1
GETDEFAULT……fix32 1
SET………….0.25 ok
SET………….1.179489 ok
SET………….2.118973 ok
SET………….3.058456 ok
SET………….3.99794 okICAP_BITDEPTH:
GET………….uint16 8
GETCURRENT……uint16 8
GETDEFAULT……uint16 8ICAP_MINIMUMHEIGHT:
GET………….fix32 0.099991ICAP_MINIMUMWIDTH:
GET………….fix32 0.099991ICAP_FLIPROTATION:
GET………….uint16 0
GETCURRENT……uint16 0
GETDEFAULT……uint16 0
SET………….0 okSection 2. Image Layout
DG_IMAGE, DAT_IMAGELAYOUT, MSG_RESET => OK.
DG_IMAGE, DAT_IMAGELAYOUT, MSG_GETDEFAULT => ( 0, 0, 8.5, 14).
DG_IMAGE, DAT_IMAGELAYOUT, MSG_GET => ( 0, 0, 8.5, 14).
DG_IMAGE, DAT_IMAGELAYOUT, MSG_SET (1.06, 2.33, 2.12, 4.66) => OK.
Scanning to verify image layout: OK
Returned image is 105 x 231 pixels, with resolution of 100 x 100 DPI
Requested resolution was: 100 x 100 DPI
Width = 1.05 (versus requested 1.06)
Height = 2.31 (versus requested 2.33)
Questions [? items]
(0) Could not set CAP_AUTOFEED to FALSE.
(1) Could not set CAP_FEEDERALIGNMENT to TWFA_RIGHT.
(2) Could not set CAP_FEEDERORDER to 0.
Compliance Issues [* items]
(0) CAP_DUPLEXENABLED: GET failed, but cap is in CAP_SUPPORTEDCAPS.
(1) ICAP_SHADOW: GET maximum value not 255.
(2) ICAP_TILES: GET after open, current value is not FALSE.
(3) CAP_FEEDERLOADED: RESET succeeded when it should fail.
(4) CAP_FEEDERALIGNMENT: RESET failed when it should succeed.
(5) CAP_FEEDERORDER: RESET failed when it should succeed.
(6) CAP_FEEDERALIGNMENT: SET failed on all values.
(7) CAP_FEEDERORDER: SET failed on all values.
End Twister Analysis.
😀I downloaded twain toolkit twister is unknownw for me I used twain toolkit for testing where can I check specifically this area on the twain toolkit code?
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 thissetvaluefor('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 floattofix32function 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 meI will give you the code and trip`lets but first I gotta to the pc that has de code 🙂 thanks
I apologize for all the screams the problem is solved 😳
- AuthorPosts