Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find duplicate pictures
How can I find duplicate pictures like ... me=d%60peg in QM?
I have a function to compare equal icons. Used it to remove duplicated icons extracted from all files in PC. Can create for bmp, gif and jpg, if you need, when will have time. With other formats can be problems.
It would be fantastic.

I was also thinking of removing duplicated files.
My algorithm would be:

Get list of files (foreach...FE_Dir),
load each (_s.getfile),
get CRC (Crc32),
store CRC/path pairs into an array or map,
find all equal CRC.

It would find any identical files.
I was looking for something like ... opic=66545
Not sure but it looks like scan in QM.
How can I find BMP in another BMP using QM?
Display bitmap1 in dialog.
Load bitmap2 using LoadPictureFile. Don't forget to DeleteObject later.
Use scan to find bitmap2 (handle) in the dialog.

Dialog is needed because scan can take bitmap1 from screen but cannot take from file or memory.
Is possible to modify scan to works from file or memory?
Is possible in a new QM version?
Forgot it, sorry. Will add in QM 2.3.2.
Do you have an estimated time?
Don't have. But I reviewed scan code and decided to not add this feature. Would need more work than I thought, and would be rarely used.
Then can you convert this function: ... ector.aspx to use with QM?
You can download free Visual Studio Express edition and try to create COM dll from the codeproject code. Then use the dll in QM.

How to export and use C# functions in QM?

Is not possible transform the code:?

Copy      Help
private Rectangle searchBitmap(Bitmap smallBmp, Bitmap bigBmp, double tolerance)
    BitmapData smallData =
      smallBmp.LockBits(new Rectangle(0, 0, smallBmp.Width, smallBmp.Height),
    BitmapData bigData =
      bigBmp.LockBits(new Rectangle(0, 0, bigBmp.Width, bigBmp.Height),

    int smallStride = smallData.Stride;
    int bigStride = bigData.Stride;

    int bigWidth = bigBmp.Width;
    int bigHeight = bigBmp.Height;
    int smallWidth = smallBmp.Width * 3;
    int smallHeight = smallBmp.Height;

    Rectangle location = Rectangle.Empty;
    int margin = Convert.ToInt32(255.0 * tolerance);

        byte* pSmall = (byte*)(void*)smallData.Scan0;
        byte* pBig = (byte*)(void*)bigData.Scan0;

        int smallOffset = smallStride - smallBmp.Width * 3;
        int bigOffset = bigStride - bigBmp.Width * 3;

        bool matchFound = true;

        for (int y = 0; y < bigHeight; y++)
            for (int x = 0; x < bigWidth; x++)
                byte* pBigBackup = pBig;
                byte* pSmallBackup = pSmall;

                //Look for the small picture.
                for (int i = 0; i < smallHeight; i++)
                    int j = 0;
                    matchFound = true;
                    for (j = 0; j < smallWidth; j++)
                        //With tolerance: pSmall value should be between margins.
                        int inf = pBig[0] - margin;
                        int sup = pBig[0] + margin;
                        if (sup < pSmall[0] || inf > pSmall[0])
                            matchFound = false;


                    if (!matchFound) break;

                    //We restore the pointers.
                    pSmall = pSmallBackup;
                    pBig = pBigBackup;

                    //Next rows of the small and big pictures.
                    pSmall += (smallWidth + smallOffset) * (1 + i);
                    pBig += (bigWidth * 3 + bigOffset) * (1 + i);

                //If match found, we return.
                if (matchFound)
                    location.X = x;
                    location.Y = y;
                    location.Width = smallBmp.Width;
                    location.Height = smallBmp.Height;
                //If no match found, we restore the pointers and continue.
                    pBig = pBigBackup;
                    pSmall = pSmallBackup;
                    pBig += 3;

            if (matchFound) break;

            pBig += bigOffset;


    return location;
Not possible. Also, in QM it would be too slow.
Why in QM it would be too slow?
QM code runs much slower than native code.
Thanks again. I thought that like scan is so quick...
I tried

Macro Macro7
Copy      Help
RegisterNetComComponent "$Desktop$\BitmapDetector.dll"
IDispatch d._create("BitmapDetector.BitmapDetectorForm")
double c=0
RECT r=d.searchBitmap(a b c)


Error in Macro7: unsupported argument type.

What's wrong, how load image in BITMAP variable?
Give the dll file paths. Let dll itself create Bitmap variables and load the files.
Can you show me an example?
Maybe in codeproject (in the same article) is a demo program with source code. I don't work with C# and don't know what Bitmap method loads a file.
Is possible add this function (find BMP in another BMP) with the features of new QM?
If you'll find C source code for it, compile it with __Tcc class.
Now I'm working with scan. Need to make it work better with icons on Win7 etc. Maybe also add searching in background windows and memory bitmaps.
Will you add it in the next version of QM?
Already added. Wait for QM
Thank you.

Forum Jump:

Users browsing this thread: 1 Guest(s)