Je développe un logiciel de type VNC très simple, il capture l'écran avec Bitblt et compare la nouvelle capture avec l'ancienne. J'utilise le code suivant pour la comparaison des bitmaps:
Les bitmaps ont toujours la même taille et au format 24bits. Le code semble fonctionner cependant de temps a autre j'ai des exceptions «Scan line index hors limite» ce qui me semble hautement improbable puisque les index sont toujours les mêmes il n'y a pas de raisons objectives pour qu'ils soient hors limites.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 PROCEDURE CompareBitmaps(CONST BitmapA, BitmapB: TBitmap; VAR Total, Match, Differ: INTEGER); Type TRGBTripleArray = ARRAY[WORD] OF TRGBTriple; pRGBTripleArray = ^TRGBTripleArray; Var i : Integer; j : Integer; rowA: pRGBTripleArray; rowB: pRGBTripleArray; Begin ASSERT( (BitmapA.width = BitmapB.width) AND (BitmapA.height = BitmapB.height), 'Different sizes'); BitmapA.PixelFormat := pf24bit; BitmapB.PixelFormat := pf24bit; Total := BitmapA.width * BitmapA.height; Match := 0; Differ := 0; For j := 0 To BitmapA.height-1 Do BEGIN rowA := BitmapA.Scanline[j]; rowB := BitmapB.Scanline[j]; For i := 0 To BitmapA.width-1 Do Begin If CompareMem(@rowA[i], @rowB[i], SizeOf(TRGBTriple)) Then Inc(Match) Else Inc(Differ) end; End End
Avez vous une idée de ce qui pourrait générer cette exception ?
Partager