Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Sunday, August 20, 2006 11:32:36 PM(UTC)


Groups: Registered
Posts: 4


I use Lead tools V1.45 develop by Visual Basic

I have 2 question

1. - I want to remove border  of image  by  use BorderRemove example for Visual Basic  OCX  in Help


BorderRemove example for Visual Basic

Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public hRgnAll As Long
Private Const RGN_OR = 2

'Declare the RasterProcess object WithEvents
Public WithEvents RasterProc As LEADRasterProcess

'Create the RasterProcess object and UnlockSupport
Private Sub Form_Load()
    Set RasterProc = CreateObject("LEADRasterProcess.LEADRasterProcess. ")
    LEADRasterView1.Raster.UnlockSupport L_SUPPORT_DOCUMENT, "TestKey"
End Sub

Private Sub Command59_Click()
'Border Remove
'This example returns a region corresponding to the borders of a bitmap
'For the example, windows regions are returned in the BorderRemove Event and combined.
'In practice it would be easier and faster to just return a LEAD region representing the changes
'The border is removed from the image

Dim nRet As Integer

'Enable the doc clean event
RasterProc.EnableDocCleanEvents = True

'Create a NULL region
hRgnAll = CreateRectRgn(0, 0, 0, 0)
nRet = RasterProc.BorderRemove(LEADRasterView1.Raster, _
                               BORDER_CALLBACK_REGION + BORDER_USE_VARIANCE, _
                               BORDER_ALL, 20, 9, 3)
If (nRet = 0) Then
    LEADRasterView1.Raster.SetRgnHandle hRgnAll, 0, 0, L_RGN_SET
    LEADRasterView1.RgnFrameType= RGNFRAME_COLOR
End If
'delete the Windows Rgn
DeleteObject hRgnAll
End Sub

Private Sub RasterProc_BorderRemove(ByVal hRgn As Long, ByVal uBorderToRemove As Long, ByVal fBoundingRectLeft As Single, ByVal fBoundingRectTop As Single, ByVal fBoundingRectWidth As Single, ByVal fBoundingRectHeight As Single)
    Dim szBorder As String
    CombineRgn hRgnAll, hRgnAll, hRgn, RGN_OR
    Select Case (uBorderToRemove)
        Case BORDER_TOP:
            szBorder = "Top"
        Case BORDER_LEFT:
            szBorder = "Left"
        Case BORDER_RIGHT:
            szBorder = "Right"
        Case BORDER_BOTTOM:
            szBorder = "Bottom"
    End Select
    Debug.Print "Border - " & szBorder & " Bounds:" & CStr(fBoundingRectLeft) & ", " & CStr(fBoundingRectTop) & ", " & CStr(fBoundingRectWidth) & ", " & CStr(fBoundingRectHeight); ""
    RasterProc.DocCleanSuccess = SUCCESS_REMOVE
End Sub



It found Error in   this line  "nRet = RasterProc.BorderRemove(LEADRasterView1.Raster, _
                               BORDER_CALLBACK_REGION + BORDER_USE_VARIANCE, _
                               BORDER_ALL, 20, 9, 3) "

It return Error  20143 = ERROR_DOCUMENT_NOT_ENABLED = 20143            ' Document capability is required to use this function

How To do for fix this error.


2.  I want separate image  i  scan image in  A3 size but in A3 paper have  A4 * 2 page (plase see in Attach file ) i want to separate one  A3 paper to A4 * 2 files. How to do.


Thank You.


pramarn attached the following image(s):

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, August 21, 2006 1:12:20 AM(UTC)


Groups: Registered
Posts: 4

Quest ion 3

I want to check blank page to delete  how to do ?


thank you

pramarn attached the following image(s):
#3 Posted : Wednesday, August 23, 2006 6:10:37 AM(UTC)

Adnan Ismail  

Groups: Guests
Posts: 3,034

Was thanked: 1 time(s) in 1 post(s)

1) The error code is generated because this function only works in Document and Medical Imaging toolkits, do you have one of these toolkits?

2) To split a large image into 2 smaller images, you need to use two controls, one to create an empty small bitmap and the other to load the original large bitmap. Use the CreateBitmap method to create an empty half-size image, then use the Combine method to copy half of the A3 image to the created bitmap. Then use the Trim method to delete the copied data from the original A3 image.

For code samples about creating, combining and trimming a bitmap, please refer to the following topics in LEADTOOLS Main OCX Help File:

1. CreateBitmap method (Main Control)
2. Trim example for Visual Basic
3. Combine example for Visual Basic

3) To detect an empty page, one way to do that is to calculate the ratio of white pixels to total image pixels, and if it's above a certain threshold value, consider it empty. Ideally, the threshold should be very close or equal to 100%, but you always get some noise when scanning real pages.
The code will look something like this:

Const BlankWhiteThreshold = 99.995 'choose your own value
Dim WhitePercent As Double
'define a region of all white pixels
LEAD1.SetRgnColor vbWhite, L_RGN_SET
'calculate ratio of white to image area
WhitePercent = 100 * LEAD1.GetRgnArea / (LEAD1.BitmapWidth * LEAD1.BitmapHeight)
If WhitePercent > BlankWhiteThreshold Then
   MsgBox "image is blank"
   MsgBox "NOT blank"
End If

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.345 seconds.