图片:
图片:
出现lcd显示颜色正确,截图拍照以后出现奇怪的色块,求大神指导。!图2是用手机闪光灯照着摄像头。
#include <sys/time.h>
#include <sys/types.h>
#include <asm/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <errno.h>
//#include <jpeglib.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/videodev2.h>
#include <linux/fb.h>
#include <linux/input.h>
#define COLS 480
#define ROWS 272
#define V4L2_DEV_NODE "/dev/video0"
#define FB_DEV_NODE "/dev/fb0"
#define CLEAR(x) memset(&(x),0,sizeof(x))
typedef struct v4l2_format V_FORMAT;
typedef struct fb_var_screeninfo F_VINFO;
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
char * fb_base_addr = NULL;
static void RGB565toRGB555(unsigned char *rgb555,unsigned char *rgb565 ,int axres,int byres) //555
{
int i,j;
unsigned short *dot;
printf("in RGB565toRGB555 %d\n");
for(i = 0; i < axres; i++)
{
for(j = 0; j < byres; j++)
{
dot = (unsigned short *)(rgb565 + i * byres + j);
*rgb555 = (((*dot)&0xffc0) >> 1)|((*dot)&0x01F);
rgb565++;
}
}
printf("out RGB16toRGB24 %d\n");
}
static void RGB16toRGB24(int *rgb24,unsigned char *rgb16 ,int axres,int byres) //555
{
int i,j;
unsigned short *dot;
printf("in RGB16toRGB24 %d\n");
for(i = 0; i < axres; i++)
{
for(j = 0; j < byres; j++)
{
dot = (unsigned short *)(rgb16 + i * byres + j);
*rgb24 = (((*dot)&0x01F) << 3); //R
rgb24++;
*rgb24 = (((*dot)&0x03E0) >> 2); //G
rgb24++;
*rgb24 = (((*dot)&0x7C00) >> 7); //B
rgb24++;
}
}
printf("out RGB16toRGB24 %d\n");
}
static int bmp_write(unsigned char *image, int xsize, int ysize, char *filename)
{
long file_size;
long width;
long height;
char fname_bmp[128];
FILE *fp;
// typedef struct tagBITMAPFILEHEADER{
//
// UINT bfType; // 2×Öœú£¬žÃÖμ±ØDèêÇ0x4D42£¬ò2ŸíêÇ×Ö·û'BM'
// DWORD bfSize; // 4×Öœú£¬ÕûžöbmpÎÄŒtμÄŽóD¡
// UINT bfReserved1; // 2×Öœú£¬±£áô£¬±ØDëéèÖÃÎa0
// UINT bfReserved2; // 2×Öœú£¬±£áô£¬±ØDëéèÖÃÎa0
// DWORD bfOffBits; // 4×Öœú£¬ŽóÎÄŒtí·¿aêŒμœêμŒêμÄíŒÏóêyŸYÖ®ŒäμÄ×ÖœúμÄÆ«òÆá¿,¿éòÔàíœaÎabmpÎÄŒtí·3