亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rdbmp.c

?? 常好且全面的jpeg圖像壓縮算法
?? C
字號:
/* *rdbmp.c is reedited from the IJG code by Fujian Shi(fieagle@yahoo.com.cn). *This programe is desinged to transform the color bmp file to gray bmp file.Notice , *here we only hold the commmon bmp format in windows.rdbmp.c need to be compiled with  *jccolor.c. */#include "commondecls.h"		/* Common decls for cjpeg/djpeg applications *//*arrage a row buffer*/void  *alloc_one_row(size_t size_object){    return (void *) malloc(size_object);}/*arrage several rows buffer,that is a array*/LOCAL(JSAMPARRAY)alloc_sarray (JDIMENSION samplesperrow, JDIMENSION numrows)/* Allocate a 2-D sample array */{  JSAMPARRAY result;  JSAMPROW workspace;  int currow;  /* Get space for row pointers (small object) */  result = (JSAMPARRAY) alloc_one_row((size_t) (numrows * SIZEOF(JSAMPROW)));  /* Get the rows themselves (large objects) */  currow = 0;  while (currow < numrows) {    workspace = (JSAMPROW) alloc_one_row((size_t) (samplesperrow		  * SIZEOF(JSAMPLE)));    result[currow++] = workspace;      }  return result;}LOCAL(int)read_byte (bmp_source_ptr sinfo)/* Read next byte from BMP file */{  register FILE *infile =sinfo->inputfile;   register int c=0;  if ((c = getc(infile)) == EOF){    printf("The wholefile has been input");    exit (0);  }  return c;}LOCAL(void)read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)/* Read the colormap from a BMP file *//*cmalen is the number of color in the bmp image*/{  int i;  switch (mapentrysize) {  case 3:    /* BGR format (occurs in OS/2 files) */    for (i = 0; i < cmaplen; i++) {      sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);      sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);      sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);    }    break;  case 4:    /* BGR0 format (occurs in MS Windows files) */    for (i = 0; i < cmaplen; i++) {      sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);      sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);      sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);      (void) read_byte(sinfo);    }    break;  default:    exit (0);    break;  }}/* * Read one row of pixels. * The image has been read into the whole_image array, but is otherwise * unprocessed.  We must read it out in top-to-bottom row order, and if * it is an 8-bit image, we must expand colormapped pixels to 24bit format. */LOCAL(void)adjust_8bit_row (bmp_source_ptr sinfo)/*This version is for reading 8-bit colormap indexes*/ {  register JSAMPARRAY colormap = sinfo->colormap;  register int t;  register JSAMPROW inptr=sinfo->buffer, outptr=sinfo->rgb_buffer;  register JDIMENSION col;  for (col = sinfo->image_width; col > 0; col--) {    t = (INT32) (*inptr++);    *outptr++ = colormap[0][t];	    *outptr++ = colormap[1][t];    *outptr++ = colormap[2][t];  }}LOCAL(void)adjust_24bit_row (bmp_source_ptr sinfo)/* This version is for reading 24-bit pixels */{   register JSAMPROW inptr=sinfo->buffer, outptr=sinfo->rgb_buffer;  register JDIMENSION col;    /* Transfer data.  Note source values are in BGR order   * (even though Microsoft's own documents say the opposite).   */  for (col = sinfo->image_width; col > 0; col--) {    outptr[2] = *inptr++;    outptr[1] = *inptr++;	    outptr[0] = *inptr++;    outptr += 3;  }}/* * This method loads the image line by line * get_pixel_rows.  The get_pixel_rows pointer is then adjusted to call * get_8bit_row or get_24bit_row on subsequent calls. */LOCAL(void)transform_image (bmp_source_ptr sinfo,bmp_destination_ptr dinfo){  register FILE *infile = sinfo->inputfile;  register FILE *outfile=dinfo->outputfile;  register int c;  register JSAMPROW in_buffer_ptr,out_buffer_ptr,\                                         in_rgb_buffer;  /*buffer pointer,the buffer is only one row*/  JDIMENSION row, col;  long position_adju;  /* read and write data. */  for (row = 0; row < (sinfo->image_height); row++) {        in_buffer_ptr=sinfo->buffer;    in_rgb_buffer=sinfo->rgb_buffer;    out_buffer_ptr=dinfo->buffer;            for (col = sinfo->row_width; col > 0; col--) {  /*by the cycle input one row sample into the buffer*/      /* inline copy of read_byte() for speed */      if ((c = getc(infile)) == EOF)	exit(0);      *in_buffer_ptr++ = (JSAMPLE) c;    }          /* adjust bgr to rgb  */    (*sinfo->adjust_pixel_rows) (sinfo);        /*rgb to gray*/    rgb_gray_convert(sinfo,dinfo);          /*write one row to the new gray bmp file*/    if (!WriteOK(dinfo->outputfile,dinfo->buffer,dinfo->row_width)){      printf("the data cann't be write into the new image.\n");        exit(0);    }  }  }/* * Read the file header; return image size and component count. */LOCAL(void)jinit_transform (bmp_source_ptr sinfo,bmp_destination_ptr dinfo){  static void  write_byte_to_buffer(JSAMPROW new_bmp_header,int offset,int data);  U_CHAR bmpfileheader[14];  U_CHAR bmpinfoheader[64];  U_CHAR new_bmp_header[54];       /*Iclude the fileheader and infoheader*/  U_CHAR _gray_colormap[256*4];  #define GET_2B(array,offset)  ((unsigned int) UCH(array[offset]) + \			       (((unsigned int) UCH(array[offset+1])) << 8))  #define GET_4B(array,offset)  ((INT32) UCH(array[offset]) + \			       (((INT32) UCH(array[offset+1])) << 8) + \			       (((INT32) UCH(array[offset+2])) << 16) + \			       (((INT32) UCH(array[offset+3])) << 24))   INT32 map_data;  JSAMPROW gray_colormap;  INT32 bfOffBits;  INT32 headerSize;  INT32 biWidth = 0;		/* initialize to avoid compiler warning */  INT32 biHeight = 0;  unsigned int biPlanes;  INT32 biCompression;  INT32 biXPelsPerMeter,biYPelsPerMeter;  INT32 biClrUsed = 0;  int mapentrysize = 0;		/* 0 indicates no colormap */  INT32 bPad;  JDIMENSION row_width;  INT32 new_filesize;  INT32 new_bfOffBits;  /* Read and verify the bitmap file header */  if (! ReadOK(sinfo->inputfile, bmpfileheader, 14)){    printf("error when read the head of file");    exit(0);  }    if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */{    printf("the file is not bmp format file");    exit(0);  }  bfOffBits = (INT32) GET_4B(bmpfileheader,10);  /* We ignore the remaining fileheader fields */  /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),   * or 64 bytes (OS/2 2.x).  Check the first 4 bytes to find out which.   */  if (! ReadOK(sinfo->inputfile, bmpinfoheader, 4)){    printf("Error when read infohead");    exit(0);  }    headerSize = (INT32) GET_4B(bmpinfoheader,0);  if (headerSize < 12 || headerSize > 64){    printf("the infohead is damaged");    exit(0);  }  printf("the bmpinfoheader is \%d\n",headerSize);    if (! ReadOK(sinfo->inputfile, bmpinfoheader+4, headerSize-4)){    printf("the infohead is damaged");    exit(0);  }  switch ((int) headerSize) {      case 40:  case 64:    /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */    /* or OS/2 2.x header, which has additional fields that we ignore */    biWidth = GET_4B(bmpinfoheader,4);    printf("the width of image is%d\n",biWidth);    biHeight = GET_4B(bmpinfoheader,8);    printf("the height of image is%d\n",biHeight);    biPlanes = GET_2B(bmpinfoheader,12);    sinfo->bits_per_pixel = (int) GET_2B(bmpinfoheader,14);    printf("the bits_per_pixel of image is%d\n",sinfo->bits_per_pixel);    biCompression = GET_4B(bmpinfoheader,16);    biXPelsPerMeter = GET_4B(bmpinfoheader,24);    biYPelsPerMeter = GET_4B(bmpinfoheader,28);    biClrUsed = GET_4B(bmpinfoheader,32);    /* biSizeImage, biClrImportant fields are ignored */    switch (sinfo->bits_per_pixel) {    case 8:			/* colormapped image */      mapentrysize = 4;		/* Windows uses RGBQUAD colormap */      sinfo->adjust_pixel_rows = adjust_8bit_row;      break;    case 24:			/* RGB image */      sinfo->adjust_pixel_rows = adjust_24bit_row;      break;    default:      printf("the bis of every pixel is not 8 or 24,I can't deal with it now");      break;    }    if (biPlanes != 1)      exit(0);    if (biCompression != 0)      exit(0);    if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {      /* Set JFIF density parameters from the BMP data */      sinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */      sinfo->Y_density = (UINT16) (biYPelsPerMeter/100);      sinfo->density_unit = 2;	/* dots/cm */    }    break;    default:      printf("the infohead is not 40 or 64 bytes");      exit(0);      break;  }  /* Compute distance to bitmap data --- will adjust for colormap below */  bPad = bfOffBits - (headerSize + 14);  printf("the bpad before colormap is %d\n",bPad);  /* Read the colormap, if any */  if (mapentrysize > 0) {    if (biClrUsed <= 0)      biClrUsed = 256;		/* assume it's 256 */    else if (biClrUsed > 256)      printf("the color used is not real_color and 256");    /* Allocate space to store the colormap */    sinfo->colormap=(JSAMPARRAY) (alloc_sarray      ((JDIMENSION) biClrUsed, (JDIMENSION) 3));    sinfo->colormap_used=1;    printf("the image use colormap\n");    /* and read it from the file */    read_colormap(sinfo, (int) biClrUsed, mapentrysize);    /* account for size of colormap */    bPad -= biClrUsed * mapentrysize;  }  /* Skip any remaining pad bytes */  if (bPad < 0)	{    printf("incorrect bfooffbits");		/* incorrect bfOffBits value? */    exit(0);  }  while (--bPad >= 0) {    (void) read_byte(sinfo);  }  printf("The bpad=%d\n",bPad);  /* Compute row width in file, including padding to 4-byte boundary */  if (sinfo->bits_per_pixel == 24)    row_width = (JDIMENSION) (biWidth * 3);  else    row_width = (JDIMENSION) biWidth;  while ((row_width & 3) != 0) row_width++;    sinfo->row_width = row_width;    printf("the row_width  is%d\n",row_width);    /* Allocate one-row buffer for returned data */  sinfo->buffer =(JSAMPROW) (alloc_one_row                    /*prepare for input origion image data*/    ((size_t) ((size_t) (row_width))*sizeof(JSAMPLE)));    sinfo->rgb_buffer =(JSAMPROW) (alloc_one_row                    /*prepare for rgb sequence origion image data*/    ((size_t) ((size_t) (biWidth*3))*sizeof(JSAMPLE)));     sinfo->image_width = dinfo->image_width=(JDIMENSION) biWidth;  sinfo->image_height=dinfo->image_height=(JDIMENSION) biHeight;    row_width=(JDIMENSION) biWidth;  while ((row_width & 3) != 0) row_width++;  dinfo->row_width = row_width;    dinfo->buffer =(JSAMPROW) (alloc_one_row			     ((size_t) ((size_t) (row_width))*sizeof(JSAMPLE)));      /*output buffer*/      /*now it is the time to deal with the new_bmp_header and write it into the file*/    new_bfOffBits=54+256*4;  new_filesize=new_bfOffBits+biWidth*biHeight;  *(new_bmp_header)=0x42;  *(new_bmp_header+1)=0x4D;    write_byte_to_buffer(new_bmp_header,2,new_filesize);  write_byte_to_buffer(new_bmp_header,10,new_bfOffBits);  write_byte_to_buffer(new_bmp_header,14,40);  write_byte_to_buffer(new_bmp_header,18,dinfo->image_width);  write_byte_to_buffer(new_bmp_header,22,dinfo->image_height);  write_byte_to_buffer(new_bmp_header,26,0x00080001);              /*biplane is 1,8 bits per pixel*/  write_byte_to_buffer(new_bmp_header,30,0);  write_byte_to_buffer(new_bmp_header,34,dinfo->image_height*dinfo->row_width);  write_byte_to_buffer(new_bmp_header,38,biXPelsPerMeter);  write_byte_to_buffer(new_bmp_header,42,biYPelsPerMeter);  write_byte_to_buffer(new_bmp_header,44,0);  write_byte_to_buffer(new_bmp_header,48,0);      /*write the header into the file*/  if (!WriteOK(dinfo->outputfile,new_bmp_header,54)){     printf("the data cann't be write into the new image.\n");        exit(0);  }   /*now we need to output the colormap*/  gray_colormap=_gray_colormap;  for (map_data=0;map_data<256;map_data++){    *gray_colormap++=(U_CHAR)map_data;    *gray_colormap++=(U_CHAR)map_data;    *gray_colormap++=(U_CHAR)map_data;    *gray_colormap++=0;  }  /*write the gray_colormap into the file*/  if (!WriteOK(dinfo->outputfile,_gray_colormap,256*4)){     printf("the data cann't be write into the new image.\n");        exit(0);  } }/*write_byte_to_buffer can input a 32bits data byte by byte to the buffer*/LOCAL(void)write_byte_to_buffer(JSAMPROW new_bmp_header,int offset,int data){  int j;  unsigned char c;  for (j=0;j<=3;j++){    *(new_bmp_header+offset+j)=( U_CHAR) (data);    data>>=8;  }}/*free the memory*/LOCAL(void)free_mem(bmp_source_ptr sinfo){  int i;  free((void *)(sinfo->buffer));  free((void *)(sinfo->rgb_buffer));  free((void *)(sinfo->rgb_gray_tab));  if (sinfo->colormap_used){    for (i=0;i<=2;i++)      free((void *) (sinfo->colormap[i]));    free((void *) (sinfo->colormap));  } }  main(int argc,char *argv[])    {            bmp_source_struct main_sinfo;      bmp_source_ptr sinfo=&main_sinfo;      bmp_destination_struct main_dinfo;      bmp_destination_ptr dinfo=&main_dinfo;      sinfo->colormap_used=0;               /*We asume the image is real-color image*/      if((sinfo->inputfile=fopen(argv[1],"rb"))==NULL){	printf("The %s can't be opended\n",argv[1]);	exit(0);      }      if((dinfo->outputfile=fopen(argv[2],"wb+"))==NULL){	printf("The %s can't be created\n",argv[2]);	exit(0);      }      jinit_color_transform(sinfo);            jinit_transform(sinfo,dinfo);            transform_image(sinfo,dinfo);      free_mem(sinfo);      free((void *)(dinfo->buffer));      fclose(sinfo->inputfile);      fclose(dinfo->outputfile);     }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品三级电影| 91精品蜜臀在线一区尤物| 欧美国产一区二区| 国产91在线看| 中文字幕一区二区三区精华液| jlzzjlzz亚洲日本少妇| 精品亚洲成a人| 久久久久久久久岛国免费| 国产精品99久久久久久久女警| 欧美国产精品中文字幕| 色婷婷综合久久久久中文| 午夜影院在线观看欧美| 欧美成人官网二区| 99精品欧美一区| 午夜精品久久久久久久99水蜜桃| 4438成人网| 懂色av一区二区三区免费看| 亚洲欧美一区二区三区极速播放| 欧洲日韩一区二区三区| 久久国产日韩欧美精品| 国产精品美女久久久久久| 在线观看视频一区| 久国产精品韩国三级视频| 国产精品二三区| 欧美久久一二三四区| 久久国产夜色精品鲁鲁99| 亚洲日本在线天堂| 日韩你懂的在线播放| 懂色av一区二区在线播放| 亚洲成人免费观看| 国产亚洲一区二区三区| 精品视频999| 懂色av一区二区夜夜嗨| 婷婷夜色潮精品综合在线| 国产亚洲精品中文字幕| 欧美视频中文字幕| 国产精品一品视频| 亚洲二区在线观看| 国产精品久线观看视频| 日韩免费一区二区| 欧美中文字幕一二三区视频| 国产在线播放一区| 婷婷成人激情在线网| 中文字幕乱码久久午夜不卡| 91精品欧美一区二区三区综合在 | 不卡一区二区三区四区| 亚洲狠狠爱一区二区三区| 国产清纯白嫩初高生在线观看91| 欧美日韩黄色影视| 91色九色蝌蚪| 国产成人亚洲综合a∨婷婷| 美女国产一区二区三区| 亚洲一卡二卡三卡四卡| 18成人在线视频| 久久久99精品久久| 日韩欧美国产小视频| 欧美日韩精品三区| 欧美中文字幕一区二区三区| 99精品黄色片免费大全| 国产乱理伦片在线观看夜一区| 亚洲成人1区2区| 一区二区国产视频| 最新国产精品久久精品| 国产欧美精品一区二区色综合 | 日韩av电影天堂| 亚洲视频一区在线| 国产亚洲综合性久久久影院| 欧美一区国产二区| 欧美日韩中文一区| 91高清视频免费看| 色婷婷av一区二区三区大白胸| 成人av网站免费| 国产91清纯白嫩初高中在线观看| 韩国一区二区视频| 国产一区二区三区在线看麻豆| 久久机这里只有精品| 久久er99热精品一区二区| 美日韩黄色大片| 久久精品久久99精品久久| 免费看欧美美女黄的网站| 日韩中文字幕亚洲一区二区va在线| 亚洲一区自拍偷拍| 亚洲bt欧美bt精品777| 亚洲电影一区二区| 日韩黄色在线观看| 久色婷婷小香蕉久久| 国内精品第一页| 国产精品538一区二区在线| 国产成人av一区二区三区在线| 国产精品自拍在线| 成av人片一区二区| 欧美亚洲动漫另类| 欧美一区二区日韩| 日本一区二区三区久久久久久久久不| 国产欧美一区在线| 亚洲精品国产无天堂网2021 | 韩国一区二区三区| 成人av资源下载| 在线观看成人小视频| 欧美日韩久久久久久| 日韩精品一区二区三区中文精品 | 久久九九久精品国产免费直播| 久久一区二区三区国产精品| 亚洲国产激情av| 一区二区三区日韩在线观看| 日日摸夜夜添夜夜添精品视频| 久久精品久久综合| 91污在线观看| 欧美一区二区免费视频| 国产欧美日韩在线看| 亚洲精品免费播放| 免费成人深夜小野草| 成人精品一区二区三区四区| 欧美优质美女网站| 精品国产一二三| 亚洲在线免费播放| 国产美女精品人人做人人爽| 色婷婷综合久久久中文字幕| 日韩午夜中文字幕| 亚洲日本丝袜连裤袜办公室| 日韩av一二三| 色综合视频在线观看| 日韩女优制服丝袜电影| 国产精品欧美经典| 久久精品国产一区二区| 色欧美片视频在线观看在线视频| 日韩三级.com| 亚洲综合精品自拍| 福利一区二区在线| 日韩视频在线观看一区二区| 亚洲欧美在线观看| 国产九色精品成人porny| 欧美日韩中文一区| 亚洲另类中文字| 国产激情视频一区二区在线观看 | 日韩精品资源二区在线| 亚洲欧美激情小说另类| 国产一区二区三区观看| 9191国产精品| 亚洲一二三区不卡| 色域天天综合网| 国产精品―色哟哟| 黄色成人免费在线| 在线综合视频播放| 亚洲成人综合视频| 91福利国产精品| 亚洲欧美偷拍三级| 波多野结衣亚洲| 欧美国产日产图区| 久久se精品一区精品二区| 337p亚洲精品色噜噜噜| 亚洲国产aⅴ成人精品无吗| jizz一区二区| 国产精品天干天干在线综合| 国产一区二区三区免费看| 欧美不卡在线视频| 麻豆一区二区99久久久久| 欧美日韩精品免费| 午夜视频在线观看一区二区三区| 91国偷自产一区二区使用方法| 中文字幕一区二区三区不卡| 成人高清免费观看| 国产精品美女久久久久aⅴ| 国产成人在线观看| 中文字幕的久久| www.久久久久久久久| 中文字幕中文在线不卡住| 成人精品视频一区二区三区尤物| 久久精品人人爽人人爽| 国产成人在线看| 国产精品二区一区二区aⅴ污介绍| 成人精品在线视频观看| 国产精品福利一区二区三区| 成人不卡免费av| 亚洲欧美视频在线观看视频| 色老汉av一区二区三区| 亚洲一区二区三区四区的| 337p亚洲精品色噜噜| 免费在线观看成人| 国产亚洲精品aa午夜观看| 成人午夜在线视频| 亚洲乱码国产乱码精品精可以看| 欧洲av在线精品| 日本女优在线视频一区二区| 欧美xxxx老人做受| 国产福利一区二区三区视频 | 欧美美女一区二区| 免费看黄色91| 国产肉丝袜一区二区| 9久草视频在线视频精品| 伊人开心综合网| 欧美福利电影网| 国产精品一卡二卡| 亚洲精品成a人| 日韩一级片在线观看| 不卡一区二区在线| 丝袜亚洲精品中文字幕一区| 久久综合久久久久88| 91女神在线视频| 美女视频黄频大全不卡视频在线播放|