Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bitmap Comparison Algorithm by creating Custom comparer
#1
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi,

Could anyone pls help to develop advanced alogorithm for fixing bitmap issues

It's Very urgent

Thanks in Advance

Remya
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi remya,
Please try this code and let me know the result.

Compare Two Images - the Visual Basic Source Code
Requires Victor Image Processing Library for 32-bit Windows v 5 or higher.

' Data type definitions ...............................................
Code:
' Image descriptor
Type imgdes
   ibuff As Long
   stx As Long
   sty As Long
   endx As Long
   endy As Long
   buffwidth As Long
   palette As Long
   colors As Long
   imgtype As Long
   bmh As Long
   hBitmap As Long
End Type

Type JpegData
    ftype As Long
    width As Long
    length As Long
    comps As Long
    precision As Long
    sampfac0 As Long
    sampfac1 As Long
    sampfac2 As Long
    sampfac3 As Long
    vbitcount As Long
End Type


' Function Declarations ...........................................
Code:
Declare Function allocimage Lib "VIC32.DLL" (image As imgdes, ByVal wid As Long, ByVal leng As Long, ByVal BPPixel As Long) As Long
Declare Sub freeimage Lib "VIC32.DLL" (image As imgdes)
Declare Function jpeginfo Lib "VIC32.DLL" (ByVal filename As String, jdat As JpegData) As Long
Declare Function loadjpg Lib "VIC32.DLL" (ByVal filename As String, resimg As imgdes) As Long
Declare Function pixelcount Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, redct As Long, grnct As Long, bluct As Long, srcimg As imgdes) As Long
Declare Function savejpg Lib "VIC32.DLL" (ByVal filename As String, srcimg As imgdes, ByVal quality As Long) As Long


' The Subroutine ..................................................
Code:
Private Sub mnucompare2pics_Click()
   Dim refimage As imgdes
   Dim testimage As imgdes
   Dim finalimage As imgdes
   Dim ref_fname As String
   Dim test_fname As String
   Dim final_fname As String
   Dim ref_fileinfo As JpegData
   Dim test_fileinfo As JpegData
   Dim rcode1 As Long
   Dim rcode2 As Long
   Dim vbitcount As Long
   Dim ared As Long
   Dim agrn As Long
   Dim ablu As Long
  
  
   ref_fname = "refc.jpg"
   test_fname = "testc.jpg"
   final_fname = "finalc.jpg"
      
    rcode1 = jpeginfo(ref_fname, ref_fileinfo)    
    rcode2 = jpeginfo(test_fname, test_fileinfo)  
    
    If ((rcode1 = NO_ERROR) And (rcode2 = NO_ERROR)) Then
    
        rcode1 = allocimage(refimage, ref_fileinfo.width, ref_fileinfo.length, ref_fileinfo.vbitcount)
        rcode2 = allocimage(testimage, test_fileinfo.width, test_fileinfo.length, test_fileinfo.vbitcount)
    
        If ((rcode1 = NO_ERROR) And (rcode2 = NO_ERROR)) Then
        
            rcode1 = loadjpg(ref_fname, refimage)    ' Load the reference image
            rcode2 = loadjpg(test_fname, testimage)  ' Load the test image      
            
            If ((rcode1 = NO_ERROR) And (rcode2 = NO_ERROR)) Then
                ' Allocate space to hold the final image      
                rcode1 = allocimage(finalimage, test_fileinfo.width, test_fileinfo.length, test_fileinfo.vbitcount)
                If (rcode1 = NO_ERROR) Then
                    ' Compare the images      
                    rcode1 = xorimage(refimage, testimage, finalimage)        ' Turns all identical pixels to zero in the final image
                    rcode2 = pixelcount(1, 255, ared, agrn, ablu, finalimage) ' Count the pixels that are nonzero      
                    If (rcode1 = NO_ERROR) And (rcode2 = NO_ERROR) And (ared > 0 Or agrn > 0 Or ablu > 0) Then
            
                        MsgBox ("pictures are different, do something")
                    End If
                
                End If
           End If
          
        End If
            
        ' Save the final image      
        rcode1 = savejpg(final_fname, finalimage, 75)

        ' Free the image buffers    
        freeimage finalimage  
        freeimage testimage
        freeimage refimage
    End If

End Sub
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Files comparison using QTP santosh.msr 0 2,168 07-11-2016, 11:38 AM
Last Post: santosh.msr
  bitmap checkpoint ch_rk2004 0 1,612 07-16-2015, 05:15 PM
Last Post: ch_rk2004
  XML diff comparison bubblehead 0 5,683 05-21-2014, 12:01 PM
Last Post: bubblehead
  How to set value to custom property ? Ranu 0 2,029 11-14-2013, 02:58 AM
Last Post: Ranu
  Creating Random String SomeIntern 0 5,049 08-21-2013, 09:10 PM
Last Post: SomeIntern

Forum Jump:


Users browsing this thread: 1 Guest(s)