Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor TCVImage.Create(Matrix: T2DIntArray);
- type
- TRGB32 = packed record B, G, R, A: Byte; end;
- TRGB24 = packed record B, G, R: Byte; end;
- TSourceMatrix = array of array of TRGB32;
- var
- X,Y,W,H: Int32;
- Source: TSourceMatrix;
- Dest: ^TRGB24;
- begin
- W := Length(Matrix[0]);
- H := Length(Matrix);
- FImage := cvCreateImage(CVSize(W, H), IPL_DEPTH_8U, 3);
- Source := TSourceMatrix(Matrix);
- dest := FImage^.ImageData;
- for Y:=0 to H - 1 do
- for x:=0 to W-1 do
- begin
- Dest^.R := Matrix[y,x].B; //matrix store colors in inverted order, so we just do R = B, B = R.
- Dest^.G := Matrix[y,x].G;
- Dest^.B := Matrix[y,x].R;
- Inc(Dest);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement