Janilabo

GetMatrixTPAColors

Oct 24th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.34 KB | None | 0 0
  1. procedure GetMatrixTPAColors(matrix: T2DIntegerArray; var TPA: TPointArray; var colors: TIntegerArray);
  2. var
  3.   x, y, z, w, h, l, i: Integer;
  4. begin
  5.   z := 0;
  6.   h := High(matrix);
  7.   for y := 0 to (h - 1) do
  8.   begin
  9.     w := High(matrix[y]);
  10.     if (w > 0) then
  11.     begin
  12.       l := (z + w);
  13.       SetLength(TPA, l);
  14.       SetLength(colors, l);
  15.       for x := 0 to (w - 1) do
  16.       begin
  17.         i := (z + x);
  18.         TPA[i].X := x;
  19.         TPA[i].Y := y;
  20.         colors[i] := matrix[y][x];
  21.       end;
  22.       z := l;
  23.     end;
  24.   end;
  25.   SetLength(TPA, z);
  26.   SetLength(colors, z);
  27. end;
  28.  
  29. procedure DebugBitmap(bmp: Integer);
  30. var
  31.   w, h: Integer;
  32. begin
  33.   GetBitmapSize(bmp, w, h);
  34.   DisplayDebugImgWindow(w, h);
  35.   DrawBitmapDebugImg(bmp);
  36. end;
  37.  
  38. var
  39.   pixels: T2DIntegerArray;
  40.   bmp: Integer;
  41.   TPA: TPointArray;
  42.   color: TIntegerArray;
  43.  
  44. begin
  45.   bmp := CreateBitmap(10, 5);
  46.   SetLength(pixels, 5);
  47.   pixels[0] := [255, 255, 0, 0, 65535, 65535, 0, 0, 255, 255];
  48.   pixels[1] := [255, 255, 0, 0, 65535, 65535, 0, 0, 255, 255];
  49.   pixels[2] := [255, 255, 0, 0, 65535, 65535, 0, 0, 255, 255];
  50.   pixels[3] := [255, 255, 0, 0, 65535, 65535, 0, 0, 255, 255];
  51.   pixels[4] := [255, 255, 0, 0, 65535, 65535, 0, 0, 255, 255];
  52.   GetMatrixTPAColors(pixels, TPA, color);
  53.   FastSetPixels(bmp, TPA, color);
  54.   DebugBitmap(bmp);
  55.   FreeBitmap(bmp);
  56. end.
Advertisement
Add Comment
Please, Sign In to add comment