The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Java Tech: Acquire Images with TWAIN and SANE, Part 2
Subject:  Setting other ICAP properties in scanner...
Date:  2005-05-25 23:21:55
From:  camikiller
Response to: Setting other ICAP properties in scanner...


i was trying :


JNIEXPORT void JNICALL Java_net_javajeff_jtwain_JTwain_setFrames
(JNIEnv * env, jclass clazz, jfloat left, jfloat top, jfloat right, jfloat bottom)
{

// Set the current value of the ICAP_FRAMES capability.

//pTW_CAPABILITY cap = (pTW_CAPABILITY)GlobalAlloc(GHND,(sizeof(TW_CAPABILITY)));
TW_CAPABILITY cap;


cap.Cap = ICAP_FRAMES;
cap.ConType = TWTY_FRAME;


pTW_FRAME pFrame = (pTW_FRAME)GlobalAlloc(GHND,(sizeof(TW_FRAME)));

pFrame->Left = FloatToFIX32(left);
pFrame->Top = FloatToFIX32(top);
pFrame->Right = FloatToFIX32(right);
pFrame->Bottom = FloatToFIX32(bottom);


// Application must allocate memory for the capability container.

cap.hContainer = GlobalAlloc(GHND,(sizeof(TW_ONEVALUE)));//+sizeof(TW_FRAME)));
if (cap.hContainer == 0)
{
throwJTE (env, "Insufficient memory (setFrames)");

return;
}

printf("OHHH\n");


// Lock memory handle so that container's fields can be populated.

TW_ONEVALUE * pTWOneValue = (TW_ONEVALUE *) GlobalLock (cap.hContainer);


// Populate container with appropriate data type and Physical Width
pTWOneValue->ItemType = TWTY_FRAME;
pTWOneValue->Item = *((pTW_UINT32) pFrame);


// Unlock memory handle.
GlobalUnlock(cap.hContainer);



g_rc = (*g_pDSM_Entry) (&g_AppID,
&g_SrcID,
DG_CONTROL,
DAT_CAPABILITY,
MSG_SET,
(TW_MEMREF) &cap);

printf("OHHH\n");

// If new current value could not be set, throw an appropriate exception.

if (g_rc != TWRC_SUCCESS)
{
// Determine if new current value could not be set because capability
// is not supported.

TW_STATUS status;

int rc = (*g_pDSM_Entry) (&g_AppID,
&g_SrcID,
DG_CONTROL,
DAT_STATUS,
MSG_GET,
(TW_MEMREF) &status);

// Throw appropriate exception.

if (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_BADCAP)
throwUC (env, "ICAP_FRAMES");
else
throwJTE (env, "Unable to set capability (setFrames)");
}


// Application is responsible for freeing any memory that it allocates. The
// data source is not responsible for this task.

GlobalFree(pFrame);
GlobalFree(cap.hContainer);
// GlobalFree(cap);

printf("OHHH\n");
}



and other variations with no success...

if you have another idea... it will be welcome as usual!

Best Regards!

 Feed java.net RSS Feeds