📄 yuv2rgb.pas
字号:
//把YUV图像转化成RGB图像
Function YUVToRGB(pPC_YUVFormat:Pchar;pPC_RGBFormat:Pchar;nWidth,nHeight:Integer):Integer;
Type
PMyByte = ^Byte;
Var
I,J:Integer;
pRGB,pRaw:PMyByte;
pY,pU,pV :PMyByte;
R,G,B :Integer;
Blue,Green,Red :Byte;
Begin
pRaw := PMyByte(pPC_YUVFormat);
pRGB := PMyByte(PPC_RGBFormat);
For I := 0 To nHeight-1 Do
Begin
pY := pRaw; {Y}
Inc(pRaw); {U}
pU := pRaw;
Inc(pRaw,2); {V}
pV := pRaw;
Inc(pRaw,nWidth*2-3); {逐行指针操作}
For J := 0 To nWidth - 1 Do
Begin
R := Round((1.0*pY^)+ (0.0*(pU^-128))+(1.375*(pV^-128)));
G := Round((1.0*pY^)+ (-0.34375*(pU^-128))+(-0.703125*(pV^-128)));
B := Round((1.0*pY^)+ (1.734375*(pU^-128))+(0.0*(pV^-128)));
IF (B>255) Then B:=255;
IF (B<0) Then B:=0;
IF (G>255) Then G:=255;
IF (G<0) Then G:=0;
IF (R>255) Then R:=255;
IF (R<0) Then R:=0;
Blue:=Byte(B);
Green:=Byte(G);
Red:=Byte(R);
pRGB^ := Blue;
Inc(pRGB);
pRGB^ := Green;
Inc(pRGB);
pRGB^ := Red;
Inc(pRGB);
Inc(pY,2);
IF (J mod 2) > 0 Then
Begin
Inc(pU,4);
Inc(pV,4);
End;
End;
End;
Result:=1;
End;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -