Home > Back-end >  O C to help transform the DELPHI YUY2_RGB function to display the RGB code!
O C to help transform the DELPHI YUY2_RGB function to display the RGB code!

Time:10-13

The inline void YUY2_RGB (BYTE * YUY2buff, BYTE * RGBbuff, dwords dwSize)
{
//B=1.164 (Y - 16) + 2.018 (U - 128)
//G=1.164 (Y - 16) - 0.813 (V - 128) to 0.391 (U - 128)
//R=1.164 (Y - 16) + 1.596 (V - 128)
BYTE * orgRGBbuff=RGBbuff;
For (DWORD count=0; Count {
//Y0 U0 Y1 where V0
Float Y0=* YUY2buff;
The float U=* (+ + YUY2buff);
Float Y1=* (+ + YUY2buff);
Float V=* (+ + YUY2buff);
+ + YUY2buff;
* (RGBbuff)=(BYTE) (Y0 + (1.370705 * (V - 128)));
* (+ + RGBbuff)=(BYTE) (Y0 - * (V - 128) (0.698001) - (0.337633 * (U - 128)));
* (+ + RGBbuff)=(BYTE) (Y0 + (1.732446 * (U - 128)));
* (+ + RGBbuff)=(BYTE) (Y1 + (1.370705 * (V - 128)));
* (+ + RGBbuff)=(BYTE) (Y1 - * (V - 128) (0.698001) - (0.337633 * (U - 128)));
* (+ + RGBbuff)=(BYTE) (Y1 + (1.732446 * (U - 128)));
+ + RGBbuff;
}
}



The inline void YUY2_RGB2 (BYTE * YUY2buff, BYTE * RGBbuff, dwords dwSize)
{
//R=Y + 1.14 V
//G=Y U - 0.39-0.58 V
//B=Y + 2.03 U
//R=Y + 1.403 V '
//G=Y - 0.344 U '- 0.714 V
//B=Y + 1.770 U '
BYTE * orgRGBbuff=RGBbuff;
For (DWORD count=0; Count {
//Y0 U0 Y1 where V0
Float Y0=* YUY2buff;
The float U=* (+ + YUY2buff);
Float Y1=* (+ + YUY2buff);
Float V=* (+ + YUY2buff);
+ + YUY2buff;
Float R, G, B;

R=(Y0 + 1.14 f * V);
G=(Y0 U - 0.58-0.39 f * f * V);
B=(2.03 f * Y0 + U).
If (R <0) R=0;
If (R> 255) R=255;
If (G <0) G=0;
If (G> 255) G=255;
If (B <0) B=0;
If (255) B> B=255;
* (RGBbuff)=B (BYTE);
* (+ + RGBbuff)=G (BYTE);
* (+ + RGBbuff)=R (BYTE);
R=(Y1 + 1.14 f * V);
G=(Y1 0.39 f * f * U - 0.58 V).
B=(Y1 + 2.03 f * U);
If (R <0) R=0;
If (R> 255) R=255;
If (G <0) G=0;
If (G> 255) G=255;
If (B <0) B=0;
If (255) B> B=255;
* (+ + RGBbuff)=B (BYTE);
* (+ + RGBbuff)=G (BYTE);
* (+ + RGBbuff)=R (BYTE);
+ + RGBbuff;
}

  • Related