Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. constructor TCVImage.Create(Matrix: T2DIntArray);
  2. type
  3. TRGB32 = packed record B, G, R, A: Byte; end;
  4. TRGB24 = packed record B, G, R: Byte; end;
  5. TSourceMatrix = array of array of TRGB32;
  6. var
  7. X,Y,W,H: Int32;
  8. Source: TSourceMatrix;
  9. Dest: ^TRGB24;
  10. begin
  11. W := Length(Matrix[0]);
  12. H := Length(Matrix);
  13. FImage := cvCreateImage(CVSize(W, H), IPL_DEPTH_8U, 3);
  14.  
  15. Source := TSourceMatrix(Matrix);
  16. dest := FImage^.ImageData;
  17. for Y:=0 to H - 1 do
  18. for x:=0 to W-1 do
  19. begin
  20. Dest^.R := Matrix[y,x].B; //matrix store colors in inverted order, so we just do R = B, B = R.
  21. Dest^.G := Matrix[y,x].G;
  22. Dest^.B := Matrix[y,x].R;
  23. Inc(Dest);
  24. end;
  25. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement