Advertisement
Janilabo

BitmapToMatrix

Nov 12th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.43 KB | None | 0 0
  1. function BitmapToMatrix(bmp: Integer): T2DIntegerArray;
  2. var
  3.   w, h, x, y, i: Integer;
  4.   p: TPointArray;
  5.   c: TIntegerArray;
  6. begin
  7.   GetBitmapSize(bmp, w, h);
  8.   p := TPAFromBox(IntToBox(0, 0, (w - 1), (h - 1)));
  9.   c := FastGetPixels(bmp, p);
  10.   SetLength(p, 0);
  11.   SetLength(Result, h, w);
  12.   i := 0;
  13.   for y := 0 to (h - 1) do
  14.     for x := 0 to (w - 1) do
  15.     begin
  16.       Result[y][x] := c[i];
  17.       i := (i + 1);
  18.     end;
  19. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement