yuyv转rgb的公式:
r = 1.164*(y-16) + 1.159*(v-128);
g = 1.164*(y-16) - 0.380*(u-128) - 0.813*(v-128);
b = 1.164*(y-16) + 2.018*(u-128);
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#define WIDTH 640
#define HEIGHT 480
#define YUYV_FILE "./0.yuyv"
#define BMP_FILE "./out.bmp"
typedef struct /**** BMP file header structure ****/
{
unsigned short bftype;
unsigned int bfSize; /* Size of file */
unsigned short bfReserved1; /* Reserved */
unsigned short bfReserved2; /* ... */
unsigned int bfOffBits; /* Offset to bitmap data */
} BITMAPFILEHEADER;
typedef struct /**** BMP file info structure ****/
{
unsigned int biSize; /* Size of info header */
int biWidth; /* Width of image */
int biHeight; /* Height of image */
unsigned short biPlanes; /* Number of color planes */