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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? rdbmp.c~

?? 常好且全面的jpeg圖像壓縮算法
?? C~
字號:
/* * This file and commondecls.h can finish a turn of a color bmp image. * */#include "commondecls.h"		/* Common decls for cjpeg/djpeg applications *//* Macros to deal with unsigned chars as efficiently as compiler allows */typedef unsigned char U_CHAR;#define UCH(x)	((int) (x))#define JFREAD(file,buf,sizeofbuf)  \  ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))#define JFWRITE(file,buf,sizeofbuf)  \  ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))#define	ReadOK(file,buffer,len)	(JFREAD(file,buffer,len) == ((size_t) (len)))#define WriteOK(file,buffer,len) (JFWRITE(file,buffer,len)==((size_t) (len)))#define LOCAL(type) static type/* Private version of data source object */typedef struct _bmp_source_struct * bmp_source_ptr;typedef struct _bmp_source_struct {    FILE *inputfile;              /*source file pointer*/  FILE *outputfile;                /*destination file pointer*/  JSAMPROW buffer;              /*buffer pointer*/  JSAMPARRAY colormap;		/* BMP colormap (converted to my format) */  UINT8 colormap_used;          /*the tag of the colormap,in the real_color image,the colormap isn't used*/  JDIMENSION image_width;  JDIMENSION image_height;      /* BMP image height*/  /* Needed to reverse row order ,?reserved temply.*/  /*JDIMENSION source_row;	 Current source row number */  JDIMENSION row_width;		/* Physical width of scanlines in file */  int bits_per_pixel;		/* remembers 8- or 24-bit format */ UINT16 X_density ;             /* 100 cm per meter */ UINT16 Y_density ; UINT8  density_unit ;  	/* dots/cm */  } bmp_source_struct;/*arrage a row buffer*/LOCAL(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(JDIMENSION) get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) *This version is for reading 8-bit colormap indexes* {  bmp_source_ptr source = (bmp_source_ptr) sinfo;  register JSAMPARRAY colormap = source->colormap;  JSAMPARRAY image_ptr;  register int t;  register JSAMPROW inptr, outptr;  register JDIMENSION col;  * Fetch next row from virtual array *  source->source_row--;  image_ptr = (*cinfo->mem->access_virt_sarray)    ((j_common_ptr) cinfo, source->whole_image,     source->source_row, (JDIMENSION) 1, FALSE);  * Expand the colormap indexes to real data *  inptr = image_ptr[0];  outptr = source->pub.buffer[0];  for (col = cinfo->image_width; col > 0; col--) {    t = GETJSAMPLE(*inptr++);    *outptr++ = colormap[0][t];	* can omit GETJSAMPLE() safely *    *outptr++ = colormap[1][t];    *outptr++ = colormap[2][t];  }  return 1;}*//*METHODDEF(JDIMENSION)get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)* This version is for reading 24-bit pixels *{  bmp_source_ptr source = (bmp_source_ptr) sinfo;  JSAMPARRAY image_ptr;  register JSAMPROW inptr, outptr;  register JDIMENSION col;  * Fetch next row from virtual array *  source->source_row--;  image_ptr = (*cinfo->mem->access_virt_sarray)    ((j_common_ptr) cinfo, source->whole_image,     source->source_row, (JDIMENSION) 1, FALSE);  * Transfer data.  Note source values are in BGR order   * (even though Microsoft's own documents say the opposite).   *  inptr = image_ptr[0];  outptr = source->pub.buffer[0];  for (col = cinfo->image_width; col > 0; col--) {    outptr[2] = *inptr++;	* can omit GETJSAMPLE() safely *    outptr[1] = *inptr++;    outptr[0] = *inptr++;    outptr += 3;  }  return 1;}*//* * This method loads the image into whole_image during the first call on * get_pixel_rows.  The get_pixel_rows pointer is then adjusted to call * get_8bit_row or get_24bit_row on subsequent calls. */LOCAL(JDIMENSION)process_image (bmp_source_ptr sinfo){  register FILE *infile = sinfo->inputfile;  register FILE *outfile=sinfo->outputfile;  register int c;  register JSAMPROW buffer_ptr;             /*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++) {        buffer_ptr=sinfo->buffer;       /*out_ptr = image_ptr[0];*/    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);      *buffer_ptr++ = (JSAMPLE) c;            if(row==(sinfo->image_height-1)&&(col==2||col==1))      printf("the oribmp.bmp last pixel element is%d\n",c);       }       position_adju=(long) ((row+1)*sinfo->row_width);       /*Whether it is need to add 2 depend on the image format,     *normally it is 24 bit bmp image.     */     fseek(outfile,-position_adju,SEEK_END);     if(!WriteOK(outfile,sinfo->buffer,sinfo->row_width)){      printf("the data cann't be write into the new image.\n");  	 exit(0);    }          }    /* Set up to read from the virtual array in top-to-bottom order *  switch (sinfo->bits_per_pixel) {  case 8:    source->pub.get_pixel_rows = get_8bit_row;    break;  case 24:    source->pub.get_pixel_rows = get_24bit_row;    break;  default:    ERREXIT(cinfo, JERR_BMP_BADDEPTH);  }  source->source_row = cinfo->image_height;  * And read the first row *  return (*source->pub.get_pixel_rows) (cinfo, sinfo); */}/* * Read the file header; return image size and component count. */LOCAL(void)start_input_bmp (bmp_source_ptr sinfo){  U_CHAR bmpfileheader[14];  U_CHAR bmpinfoheader[64];#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 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;  /* 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 12:    * Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) *    biWidth = (INT32) GET_2B(bmpinfoheader,4);    biHeight = (INT32) GET_2B(bmpinfoheader,6);    biPlanes = GET_2B(bmpinfoheader,8);    source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10);    switch (source->bits_per_pixel) {    case 8:			* colormapped image *      mapentrysize = 3;		* OS/2 uses RGBTRIPLE colormap *      TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight);      break;    case 24:			* RGB image *      TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight);      break;    default:      ERREXIT(cinfo, JERR_BMP_BADDEPTH);      break;    }    if (biPlanes != 1)      ERREXIT(cinfo, JERR_BMP_BADPLANES);    break;*/  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 */      break;    case 24:			/* RGB image */      printf("WARNNING!Maybe it is needed to add 2 for the position shift.\n");      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    ((size_t) ((size_t) (row_width))*sizeof(JSAMPLE)));    sinfo->image_width = (JDIMENSION) biWidth;  sinfo->image_height = (JDIMENSION) biHeight;}/*free the memory*/LOCAL(void)free_mem(bmp_source_ptr sinfo){  int i;  free((void *)(sinfo->buffer));  for (i=0;i<=2;i++)    free((void *) (sinfo->colormap[i]));  if(sinfo->colormap_used)    free((void *) (sinfo->colormap));   }  main(int argc,char *argv[])    {      bmp_source_struct main_sinfo;      bmp_source_ptr sinfo=&main_sinfo;      sinfo->colormap_used=0;               /*We asume the image is real-color image*/      if((sinfo->inputfile=fopen(argv[1],"rb"))==NULL)	printf("The oribmp.bmp can't be opended");      if((sinfo->outputfile=fopen(argv[2],"rb+"))==NULL)	printf("The newbmp.bmp can't be opended");      start_input_bmp(sinfo);      process_image(sinfo);      free_mem(sinfo);      /*fseek(sinfo->inputfile,-2,2);	printf("the mumber is%d\n",getc(sinfo->inputfile));*/      fclose(sinfo->inputfile);      fclose(sinfo->outputfile);     }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩电影在线播放| 精品理论电影在线观看| 欧美成人午夜电影| 亚洲天天做日日做天天谢日日欢| 国产精品资源在线看| 91在线丨porny丨国产| 日韩欧美精品在线视频| 一区二区三区久久| 成人国产精品免费观看动漫| 欧美一区二区三区免费视频| 亚洲欧美综合另类在线卡通| 美女国产一区二区三区| 欧美日韩一级片在线观看| 国产精品网站一区| 国产精品一区二区三区网站| 日韩一区二区三区三四区视频在线观看 | 亚洲影院理伦片| 成人综合在线视频| 精品国产乱码久久久久久闺蜜| 亚洲国产精品一区二区www在线| 91在线精品一区二区| 国产精品丝袜在线| 国产成人免费高清| 国产欧美视频在线观看| 国模大尺度一区二区三区| 欧美一区二区成人| 蜜桃一区二区三区四区| 6080日韩午夜伦伦午夜伦| 一个色妞综合视频在线观看| 91免费观看视频在线| 亚洲欧美日本在线| 色狠狠综合天天综合综合| 亚洲欧洲av一区二区三区久久| www.久久久久久久久| 国产网站一区二区三区| 加勒比av一区二区| 久久久亚洲精品一区二区三区| 国产乱子伦一区二区三区国色天香| 日韩欧美在线网站| 精品一区二区影视| 久久久国产综合精品女国产盗摄| 国产福利一区二区三区| 国产精品网站一区| 91美女片黄在线观看| 亚洲精品久久久久久国产精华液| 色国产综合视频| 亚洲成在线观看| 91精品国产色综合久久| 美女视频黄 久久| 久久亚洲私人国产精品va媚药| 国内外成人在线| 欧美韩日一区二区三区| av在线一区二区| 亚洲综合网站在线观看| 欧美精品亚洲二区| 国精产品一区一区三区mba视频| 精品国产99国产精品| 成人国产精品免费观看动漫| 尤物av一区二区| 日韩亚洲欧美在线| 91猫先生在线| 久久精品国产99久久6| 国产人久久人人人人爽| 91视频观看视频| 免费视频一区二区| 中日韩av电影| 欧美一区二区三区免费大片 | 国产成人日日夜夜| 成人免费在线视频观看| 欧美揉bbbbb揉bbbbb| 激情偷乱视频一区二区三区| 中文字幕佐山爱一区二区免费| 欧美色综合网站| 国产成人在线视频网站| 亚洲一二三专区| 欧美精品一区二区三区高清aⅴ| 97久久精品人人澡人人爽| 午夜亚洲国产au精品一区二区| 久久这里只有精品6| 欧美手机在线视频| 丁香六月综合激情| 欧美aaaaaa午夜精品| 亚洲青青青在线视频| 精品欧美乱码久久久久久| 一本大道综合伊人精品热热 | 成人高清视频在线观看| 日韩精品电影在线观看| 亚洲日本丝袜连裤袜办公室| 日韩精品专区在线影院观看| 欧美亚洲国产一区在线观看网站| 国产成人综合精品三级| 日本一区中文字幕| 一区二区理论电影在线观看| 久久久精品黄色| 精品人伦一区二区色婷婷| 欧美色涩在线第一页| 成人短视频下载| 国产精品系列在线播放| 久久国产精品色婷婷| 午夜av区久久| 亚洲一区二区三区小说| 欧美高清在线一区二区| 2017欧美狠狠色| 日韩欧美电影在线| 91精品国产综合久久久蜜臀粉嫩| 在线精品视频小说1| 成人看片黄a免费看在线| 国产一区激情在线| 麻豆精品蜜桃视频网站| 日韩高清欧美激情| 日韩av不卡在线观看| 午夜久久久久久电影| 一区二区不卡在线视频 午夜欧美不卡在| 国产欧美日韩另类视频免费观看| 久久夜色精品国产欧美乱极品| 日韩精品一区二区三区视频在线观看| 欧美一区二区成人| 91精品国产欧美一区二区| 69精品人人人人| 日韩一区二区在线观看视频| 日韩亚洲欧美在线| 久久综合色之久久综合| 亚洲精品在线观| 日本一区二区三区免费乱视频 | av男人天堂一区| 成人午夜精品在线| av色综合久久天堂av综合| 色综合久久久久综合体| 欧美三级乱人伦电影| 91精品国产综合久久香蕉麻豆| 日韩欧美在线网站| 国产亚洲综合在线| 亚洲视频在线观看一区| 一区二区三区欧美日韩| 秋霞成人午夜伦在线观看| 精品亚洲成a人| 成人91在线观看| 色婷婷亚洲综合| 91麻豆精品国产91久久久使用方法| 精品国产一区二区三区av性色| 欧美极品少妇xxxxⅹ高跟鞋 | 久久99精品久久久久久国产越南| 国产在线精品免费| 99精品久久99久久久久| 欧美在线免费播放| 精品1区2区在线观看| 亚洲精品乱码久久久久久久久| 日韩影院在线观看| 成人一区二区三区中文字幕| 欧美专区日韩专区| 久久久久久黄色| 亚洲在线中文字幕| 国产福利不卡视频| 欧美亚洲高清一区二区三区不卡| 欧美一级黄色大片| 自拍偷拍欧美精品| 日本aⅴ精品一区二区三区| 高清国产一区二区三区| 欧美性videosxxxxx| 久久一日本道色综合| 亚洲第一成人在线| 不卡区在线中文字幕| 日韩欧美在线123| 亚洲女与黑人做爰| 国产乱码精品一区二区三区五月婷 | 亚洲激情在线播放| 韩国成人在线视频| 欧美绝品在线观看成人午夜影视| 国产夜色精品一区二区av| 人妖欧美一区二区| 色av综合在线| 最新高清无码专区| 国产精品影音先锋| 欧美久久久久久蜜桃| 亚洲免费观看高清完整| 激情亚洲综合在线| 91精品国产综合久久久久久漫画| 中文字幕一区二区三区蜜月| 国产一区在线看| 欧美一区二区在线免费播放| 一区二区成人在线| 91伊人久久大香线蕉| 国产三级精品视频| 黄色资源网久久资源365| 欧美日韩一二区| 一区二区三区精密机械公司| 9l国产精品久久久久麻豆| 亚洲精品一区二区精华| 青青草精品视频| 欧美日韩国产一二三| 亚洲一线二线三线视频| 99久久久国产精品免费蜜臀| 国产亚洲福利社区一区| 麻豆成人在线观看| 日韩欧美三级在线| 蜜桃久久精品一区二区| 欧美精品在线观看一区二区| 首页国产欧美日韩丝袜| 欧美日韩成人一区| 天堂成人国产精品一区|