穿越千年的爱恋什么歌:RGB 888 to RGB 565
来源:百度文库 编辑:中财网 时间:2024/05/10 12:28:18
#include
#include
#include
#include
#include
#include
struct header1 {
unsigned short type;
size_t size;
unsigned short r1;
unsigned short r2;
size_t off;
} __attribute__((packed));
struct header2 {
size_t size;
long width;
long height;
unsigned short planes;
unsigned short bit_count;
unsigned long compression;
size_t img_size;
long x_pels_per_meter;
long y_pels_per_meter;
unsigned long color_used;
unsigned long color_important;
} __attribute__((packed));
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
}data24;
typedef struct {
short r;
short g;
short b;
}ERROR;
struct data16 {
unsigned short r:5;
unsigned short g:6;
unsigned short b:5;
};
void plus_truncate_uchar(unsigned char *a,char b)
{
// printf("xxx=%d\n",*a);
if(int(*a)+b>0xff)*a=0xff;
else if(int(*a)+b<0)*a=0;
else *a+=b;
//printf("yyy=%d\n",*a);
}
int main(int argc, char *argv[])
{
int fd_in, fd_out;
struct header1 in_header1;
struct header2 in_header2;
unsigned char in_buff[3] = {0};
struct data16 out_buff;
size_t i,j, n;
ERROR error;
const unsigned long red_mask = 0xF800ul;
const unsigned long green_mask = 0x07E0ul;
const unsigned long blue_mask = 0x001Ful;
short bmpwidth;
short bmpheight;
data24 **bmpBuf;
if (argc != 3) {
fprintf(stderr, "Wrong usage!\n"
"Tyr %s
#include
#include
#include
#include
#include
struct header1 {
unsigned short type;
size_t size;
unsigned short r1;
unsigned short r2;
size_t off;
} __attribute__((packed));
struct header2 {
size_t size;
long width;
long height;
unsigned short planes;
unsigned short bit_count;
unsigned long compression;
size_t img_size;
long x_pels_per_meter;
long y_pels_per_meter;
unsigned long color_used;
unsigned long color_important;
} __attribute__((packed));
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
}data24;
typedef struct {
short r;
short g;
short b;
}ERROR;
struct data16 {
unsigned short r:5;
unsigned short g:6;
unsigned short b:5;
};
void plus_truncate_uchar(unsigned char *a,char b)
{
// printf("xxx=%d\n",*a);
if(int(*a)+b>0xff)*a=0xff;
else if(int(*a)+b<0)*a=0;
else *a+=b;
//printf("yyy=%d\n",*a);
}
int main(int argc, char *argv[])
{
int fd_in, fd_out;
struct header1 in_header1;
struct header2 in_header2;
unsigned char in_buff[3] = {0};
struct data16 out_buff;
size_t i,j, n;
ERROR error;
const unsigned long red_mask = 0xF800ul;
const unsigned long green_mask = 0x07E0ul;
const unsigned long blue_mask = 0x001Ful;
short bmpwidth;
short bmpheight;
data24 **bmpBuf;
if (argc != 3) {
fprintf(stderr, "Wrong usage!\n"
"Tyr %s