Bonjour,

Il y a une dizaine d'années, j'avais récupéré le code suivant pour sélectionner une partie d'une image dans un programme conçu sous Delphi 5 :

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
 
procedure MovingDots(X, Y: Integer; ACanvas: TCanvas); stdcall;
begin
{$R-}
  Counter := Counter shl 1;           // Shift the bit left one
{$R+}
  if Counter = 0 then Counter := 1;   // If it shifts off left, reset it
  if (Counter and 224) > 0 then       // Are any of the left 3 bits set?
     ACanvas.Pixels[X, Y] := clWhite  // Erase the pixel
  else
     ACanvas.Pixels[X, Y] := clBlack; // Draw the pixel
end;
 
procedure TFiche.DrawAntsRect;
begin
  // Determines starting pixel color of Rect
  Counter := CounterStart;
 
  // Dessin des 4 cotés du rectangle de sélection
  LineDDA(X1, Y1, X2, Y1, @MovingDots, LongInt(targetCanvas));
  LineDDA(X2, Y1, X2, Y2, @MovingDots, LongInt(targetCanvas));
  LineDDA(X2, Y2, X1, Y2, @MovingDots, LongInt(targetCanvas));
  LineDDA(X1, Y2, X1, Y1, @MovingDots, LongInt(targetCanvas));
end;
Ce code me permettait d'obtenir l'effet connu sous le nom de "marching ants", reproduit sur l'image ci-contre : Nom : Marching_ants.gif
Affichages : 386
Taille : 1,8 Ko

La procédure principale DrawAntsRect faisait appel à une autre procédure, LineDDA, dépendante de l'unité Windows.
Aujourd'hui, je voudrais pouvoir reproduire cet effet sans être dépendant du système d'exploitation sous-jacent.
Cela est-il possible, et comment ?
Merci d'avance pour votre aide.