Procedure PROCEDURE p_scanA4 ( p_opt number , ----- 1 - insert 2 - update p_page_no varchar2 )IS pictint PLS_INTEGER; /* Integer value returned by Scan Picture (f_scanpict) */ cpictint PLS_INTEGER; /* mushot handle */ winhand PLS_INTEGER := TO_NUMBER (GET_WINDOW_PROPERTY (FORMS_MDI_WINDOW, WINDOW_HANDLE)); chk_cnct BOOLEAN; /* Boolean returned by Isconnect (f_dbiscnct) */ rel_mem BOOLEAN; /* Boolean returned by Release Memory (f_rel_mem) */ libhand ORA_FFI.LIBHANDLETYPE; fingerid VARCHAR2(1) := 'x'; com_pict PLS_INTEGER := 1; com_a4page PLS_INTEGER; com_a4int PLS_INTEGER := 1; com_pictint PLS_INTEGER; ins_data BOOLEAN; ins_a4 BOOLEAN; uname VARCHAR2(30) := GET_APPLICATION_PROPERTY (USERNAME); paswd VARCHAR2(30) := GET_APPLICATION_PROPERTY (PASSWORD); dname VARCHAR2(30) := 'MALAYSIA'; err_msg VARCHAR2(255); alt_num NUMBER; table_name varchar2(30):= 'MD_IMG_EMPR'; skey1 varchar2(50):= :reg_icno; skey2 varchar2(50):= :doc_no; skey3 varchar2(50):= to_char(:disp_date,'DD/MM/YYYY'); skey4 varchar2(50):= :doc_type; skey5 varchar2(50):= p_page_no; begin p_chk_null_proc; imgscan.p_dbdisconnect; /* Disconnect from the Database */ imgscan.p_dbconnect (dname, uname, paswd); /* Connect to the database using the current values */ begin chk_cnct := imgscan.f_dbiscnct; /* Check for Connection */ pictint := imgscan.f_scanpict (winhand); /* Scan the picture */ if pictint = 0 then err_msg := imgscan.f_geterror; stdispmsgstr(err_msg, TRUE); imgscan.p_unload; else cpictint := imgscan.f_display90 (pictint, winhand); -- Compress A4 page and insert com_a4page := imgscan.f_compressa4 (cpictint, com_a4int); if p_opt = 1 then skey5 := f_get_next_page(:reg_icno,:doc_type,:doc_no); ins_a4 := imgscan.f_inserta4 (table_name, skey1, skey2, skey3, skey4, skey5,com_a4page, com_a4int); else UPDATE md_img_empr set ie_reg_icno = skey1, ie_no = skey2, ie_date = skey3, ie_doc_type = skey4, ie_page_no = skey5, crewho = user, credate = sysdate where rowid = :md_img_empr.rowid; commit; ins_a4 := imgscan.f_updatea4 (table_name, skey1, skey2,skey3,skey4, skey5, com_a4page, com_a4int); end if; rel_mem := imgscan.f_rel_mem (com_a4page); rel_mem := imgscan.f_rel_mem (pictint); rel_mem := imgscan.f_rel_mem (cpictint); end if; exception when others then stdispmsgstr (to_char (sqlcode) || ' ' || sqlerrm, TRUE); imgscan.p_unload; raise form_trigger_failure; end; /* End of Exception handling begin */ break; END; Package spec PACKAGE imgscan IS -- 1 PROCEDURE doall (whand PLS_INTEGER); RETURN NUMBER; -- 2 /* This procedure unloads the DLL from memory */ PROCEDURE p_unload; -- 3 /* This function call is to scan the whole page and it needs a Window hand as argument This function returns an integer value for the picture scanned. */ FUNCTION f_scanpict (whand PLS_INTEGER) RETURN PLS_INTEGER; ---3.1 begin /* This function call is to scan and only the area specified by the Arguments Xposition, Yposition, Width and Height of the Picture color - 1 color else gray scale */ FUNCTION f_scanEx (whand PLS_INTEGER , xpos PLS_INTEGER, ypos PLS_INTEGER ,width PLS_INTEGER, height PLS_INTEGER, color PLS_INTEGER) RETURN PLS_INTEGER; ---3.1 end -- 4 /* This function releases the memory occupied by the Scanpicture function and others. If this is not called after each and every scanning, lot of memory problems will arise. So be careful and don't forget to use this function after scanning and transactions. Argument to this function is the value returned by every function call. */ FUNCTION f_rel_mem (pictint PLS_INTEGER) RETURN BOOLEAN; -- 5 /* This procedure displays the picture scanned. Arguments to this function are the value returned by every function call that returns a picture and the window handle */ PROCEDURE p_display (pictint PLS_INTEGER, whand PLS_INTEGER); -- 5-1 /* This procedure displays the picture scanned. Arguments to this function are the value returned by every function call that returns a picture and the window handle */ FUNCTION f_display90 (pictint PLS_INTEGER, whand PLS_INTEGER) RETURN PLS_INTEGER; -- 6 /* This procedure cuts the picture specified. Arguments are integer value returned by the Picture Scan function, Xposition, Yposition, Width and Height of the Picture */ FUNCTION f_cutpict (pictint PLS_INTEGER, xpos PLS_INTEGER, ypos PLS_INTEGER, width PLS_INTEGER, height PLS_INTEGER) RETURN PLS_INTEGER; -- 7 /* This procedure connect to the Database via ODBC. Arguments to be passed are Database Name, Username and the Password. */ PROCEDURE p_dbconnect (dname IN OUT VARCHAR2, uname IN OUT VARCHAR2, paswd IN OUT VARCHAR2); -- 8 /* This function checks for an Connection to the database via ODBC. If successful returns TRUE else FALSE */ FUNCTION f_dbiscnct RETURN BOOLEAN; -- 9 /* This procedure disconnects the Database connection. */ PROCEDURE p_dbdisconnect; -- 10 /* This function compresses the picture. Arguments to be passed are the picture which is cut, the picture type and the compressed picture value. Picture type has 3 predefined values : 1, 2 & 3*/ FUNCTION f_compress (cpictint PLS_INTEGER, pict_type PLS_INTEGER, com_pict IN OUT PLS_INTEGER) RETURN PLS_INTEGER; -- 11 /* This function compresses the whole A4 page. Arguments to be passed are the page and the Compressed page value. */ FUNCTION f_compressa4 (pageint PLS_INTEGER, com_a4page IN OUT PLS_INTEGER) RETURN PLS_INTEGER; -- 12 /* This function inserts data into the table. */ /* FUNCTION f_insertdata (tab_type IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) */ FUNCTION f_insertdata (tab_type IN OUT VARCHAR2, reg_icno IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) RETURN BOOLEAN; -- 13 /* This function inserts the compressed A4 page into the table. */ FUNCTION f_inserta4 (tab_type IN OUT VARCHAR2, skey1 IN OUT VARCHAR2, skey2 IN OUT VARCHAR2, skey3 IN OUT VARCHAR2, skey4 IN OUT VARCHAR2,skey5 IN OUT VARCHAR2, com_a4page IN OUT PLS_INTEGER, com_a4int IN PLS_INTEGER) RETURN BOOLEAN; -- 14 /* This function updates the value in the table. */ FUNCTION f_updatedata (tab_type IN OUT VARCHAR2, reg_icno IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) RETURN BOOLEAN; -- 15 /* This function updates the A4 page in the table */ FUNCTION f_updatea4 (tab_type IN OUT VARCHAR2, skey1 IN OUT VARCHAR2, skey2 IN OUT VARCHAR2, skey3 IN OUT VARCHAR2, skey4 IN OUT VARCHAR2, skey5 IN OUT VARCHAR2, com_a4page IN OUT PLS_INTEGER, com_a4int IN PLS_INTEGER) RETURN BOOLEAN; -- 16 /* This function gets the error message if any.*/ FUNCTION f_geterror RETURN VARCHAR2; -- 17 FUNCTION f_cutdisplay (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 17 FUNCTION f_cutdisplay90 (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 20 PROCEDURE p_do_ocr (whand PLS_INTEGER, bmp_handle PLS_INTEGER, t PLS_INTEGER); -- 21 /* This function gets the error message if any.*/ PROCEDURE p_DbInsertOCRPage; -- 22 FUNCTION f_centerphoto (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 23 PROCEDURE p_do_ocr (whand PLS_INTEGER, bmp_handle PLS_INTEGER, t PLS_INTEGER, f IN OUT VARCHAR2, b PLS_INTEGER); -- 24 /* This function gets the error message if any.*/ --PROCEDURE p_DbInsertOCRPage; -- 25 FUNCTION f_getocrpage (f IN OUT VARCHAR2) RETURN VARCHAR2; -- 26 /* This DO rotation 90% of a bitmap */ Function F_Rotate90 (pictint PLS_INTEGER) Return PLS_INTEGER; END; Package Body PACKAGE imgscan IS -- 1 PROCEDURE doall (whand PLS_INTEGER); RETURN NUMBER; -- 2 /* This procedure unloads the DLL from memory */ PROCEDURE p_unload; -- 3 /* This function call is to scan the whole page and it needs a Window hand as argument This function returns an integer value for the picture scanned. */ FUNCTION f_scanpict (whand PLS_INTEGER) RETURN PLS_INTEGER; ---3.1 begin /* This function call is to scan and only the area specified by the Arguments Xposition, Yposition, Width and Height of the Picture color - 1 color else gray scale */ FUNCTION f_scanEx (whand PLS_INTEGER , xpos PLS_INTEGER, ypos PLS_INTEGER ,width PLS_INTEGER, height PLS_INTEGER, color PLS_INTEGER) RETURN PLS_INTEGER; ---3.1 end -- 4 /* This function releases the memory occupied by the Scanpicture function and others. If this is not called after each and every scanning, lot of memory problems will arise. So be careful and don't forget to use this function after scanning and transactions. Argument to this function is the value returned by every function call. */ FUNCTION f_rel_mem (pictint PLS_INTEGER) RETURN BOOLEAN; -- 5 /* This procedure displays the picture scanned. Arguments to this function are the value returned by every function call that returns a picture and the window handle */ PROCEDURE p_display (pictint PLS_INTEGER, whand PLS_INTEGER); -- 5-1 /* This procedure displays the picture scanned. Arguments to this function are the value returned by every function call that returns a picture and the window handle */ FUNCTION f_display90 (pictint PLS_INTEGER, whand PLS_INTEGER) RETURN PLS_INTEGER; -- 6 /* This procedure cuts the picture specified. Arguments are integer value returned by the Picture Scan function, Xposition, Yposition, Width and Height of the Picture */ FUNCTION f_cutpict (pictint PLS_INTEGER, xpos PLS_INTEGER, ypos PLS_INTEGER, width PLS_INTEGER, height PLS_INTEGER) RETURN PLS_INTEGER; -- 7 /* This procedure connect to the Database via ODBC. Arguments to be passed are Database Name, Username and the Password. */ PROCEDURE p_dbconnect (dname IN OUT VARCHAR2, uname IN OUT VARCHAR2, paswd IN OUT VARCHAR2); -- 8 /* This function checks for an Connection to the database via ODBC. If successful returns TRUE else FALSE */ FUNCTION f_dbiscnct RETURN BOOLEAN; -- 9 /* This procedure disconnects the Database connection. */ PROCEDURE p_dbdisconnect; -- 10 /* This function compresses the picture. Arguments to be passed are the picture which is cut, the picture type and the compressed picture value. Picture type has 3 predefined values : 1, 2 & 3*/ FUNCTION f_compress (cpictint PLS_INTEGER, pict_type PLS_INTEGER, com_pict IN OUT PLS_INTEGER) RETURN PLS_INTEGER; -- 11 /* This function compresses the whole A4 page. Arguments to be passed are the page and the Compressed page value. */ FUNCTION f_compressa4 (pageint PLS_INTEGER, com_a4page IN OUT PLS_INTEGER) RETURN PLS_INTEGER; -- 12 /* This function inserts data into the table. */ /* FUNCTION f_insertdata (tab_type IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) */ FUNCTION f_insertdata (tab_type IN OUT VARCHAR2, reg_icno IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) RETURN BOOLEAN; -- 13 /* This function inserts the compressed A4 page into the table. */ FUNCTION f_inserta4 (tab_type IN OUT VARCHAR2, skey1 IN OUT VARCHAR2, skey2 IN OUT VARCHAR2, skey3 IN OUT VARCHAR2, skey4 IN OUT VARCHAR2,skey5 IN OUT VARCHAR2, com_a4page IN OUT PLS_INTEGER, com_a4int IN PLS_INTEGER) RETURN BOOLEAN; -- 14 /* This function updates the value in the table. */ FUNCTION f_updatedata (tab_type IN OUT VARCHAR2, reg_icno IN OUT VARCHAR2, nation IN OUT VARCHAR2, docno IN OUT VARCHAR2, fingerid IN OUT VARCHAR2, cpictint PLS_INTEGER, com_pictint IN PLS_INTEGER) RETURN BOOLEAN; -- 15 /* This function updates the A4 page in the table */ FUNCTION f_updatea4 (tab_type IN OUT VARCHAR2, skey1 IN OUT VARCHAR2, skey2 IN OUT VARCHAR2, skey3 IN OUT VARCHAR2, skey4 IN OUT VARCHAR2, skey5 IN OUT VARCHAR2, com_a4page IN OUT PLS_INTEGER, com_a4int IN PLS_INTEGER) RETURN BOOLEAN; -- 16 /* This function gets the error message if any.*/ FUNCTION f_geterror RETURN VARCHAR2; -- 17 FUNCTION f_cutdisplay (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 17 FUNCTION f_cutdisplay90 (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 20 PROCEDURE p_do_ocr (whand PLS_INTEGER, bmp_handle PLS_INTEGER, t PLS_INTEGER); -- 21 /* This function gets the error message if any.*/ PROCEDURE p_DbInsertOCRPage; -- 22 FUNCTION f_centerphoto (pictint IN PLS_INTEGER, whand IN PLS_INTEGER, xpos IN PLS_INTEGER, ypos IN PLS_INTEGER, wdth IN PLS_INTEGER, p_height IN PLS_INTEGER) RETURN PLS_INTEGER; -- 23 PROCEDURE p_do_ocr (whand PLS_INTEGER, bmp_handle PLS_INTEGER, t PLS_INTEGER, f IN OUT VARCHAR2, b PLS_INTEGER); -- 24 /* This function gets the error message if any.*/ --PROCEDURE p_DbInsertOCRPage; -- 25 FUNCTION f_getocrpage (f IN OUT VARCHAR2) RETURN VARCHAR2; -- 26 /* This DO rotation 90% of a bitmap */ Function F_Rotate90 (pictint PLS_INTEGER) Return PLS_INTEGER; END;