Autor Beitrag
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Mo 15.04.13 21:12 
Hi,

ich habe folgende Seite gefunden, die genau das zeigt, was ich nicht schaffe.
Allerdings kriege ich diesen Code nicht konvertiert, insbesondere, da ich nicht weiß, wie die Typen wie BITMAPINFO zu benutzen sind (Anscheinend sind die in C# nicht bereits typisiert).
-> www.codeproject.com/...Bitmaps-for-Equality

Weiter bin ich noch nicht gekommen -.-
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
[DllImport("user32.dll")]
        static extern IntPtr GetDC(IntPtr hWnd);

        [DllImport("gdi32.dll")]
        static extern int GetDIBits(IntPtr hdc, IntPtr hbmp, uint uStartScan, uint cScanLines, [Out] byte[] lpvBits, ref BITMAPINFO lpbmi, uint uUsage);

        [StructLayout(LayoutKind.Sequential)]
        public struct BITMAPINFOHEADER
        {
            public uint biSize;
            public int biWidth;
            public int biHeight;
            public ushort biPlanes;
            public ushort biBitCount;
            public uint biCompression;
            public uint biSizeImage;
            public int biXPelsPerMeter;
            public int biYPelsPerMeter;
            public uint biClrUsed;
            public uint biClrImportant;

            public void Init()
            {
                biSize = (uint)Marshal.SizeOf(this);
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct BITMAPINFO
        {
            public Int32 biSize;
            public Int32 biWidth;
            public Int32 biHeight;
            public Int16 biPlanes;
            public Int16 biBitCount;
            public Int32 biCompression;
            public Int32 biSizeImage;
            public Int32 biXPelsPerMeter;
            public Int32 biYPelsPerMeter;
            public Int32 biClrUsed;
            public Int32 biClrImportant;
        }

        public bool CompareBitmaps(IntPtr HBitmapLeft, IntPtr HBitmapRight)
        {
            if (HBitmapLeft == HBitmapRight)
            {
                return true;
            }

            if (HBitmapLeft == IntPtr.Zero|| HBitmapRight == IntPtr.Zero)
            {
                return false;
            }

            bool bSame = false;

            IntPtr hdc = GetDC(IntPtr.Zero);

            BITMAPINFO BitmapInfoLeft = new BITMAPINFO();
            BITMAPINFO BitmapInfoRight = new BITMAPINFO();

            BitmapInfoLeft.biSize = Marshal.SizeOf(BitmapInfoLeft);
            BitmapInfoRight.biSize = Marshal.SizeOf(BitmapInfoRight);


Für jeden Tipp bin ich sehr dankbar :)

lg
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Mo 15.04.13 21:57 
Ich würde das Bild einfach erstmal in C# als Bitmap laden ( msdn.microsoft.com/d...ibrary/k061we7x.aspx ) und dann mit zwei Schleifen pixelweise vergleichen.
HenryHux Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Di 16.04.13 08:33 
Da habe ich ja dann das Problem, dass die thredsafety nicht gegeben ist..