锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久成人国产精品,久久天天躁狠狠躁夜夜avapp,久久综合狠狠综合久久http://m.shnenglu.com/izualzhy/category/20414.html鍧氭寔 鐩鎬俊鑷繁zh-cnSat, 09 Mar 2013 17:48:49 GMTSat, 09 Mar 2013 17:48:49 GMT60BMP鏍煎紡瀛︿範涔嬭漿鎹mp涓哄瓧絎︾敾http://m.shnenglu.com/izualzhy/archive/2013/03/09/198322.htmlizualzhyizualzhySat, 09 Mar 2013 15:38:00 GMThttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198322.htmlhttp://m.shnenglu.com/izualzhy/comments/198322.htmlhttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198322.html#Feedback0http://m.shnenglu.com/izualzhy/comments/commentRss/198322.htmlhttp://m.shnenglu.com/izualzhy/services/trackbacks/198322.html浜庢槸璇曠潃鑷繁鍐欎簡涓紝鏁堟灉涓鑸絾鏄緢鏈夋剰鎬濄傜敱浜庢垜浣跨敤鐨勬槸256鑹茬殑bmp錛屽彲鑳戒嬌鐢?4浣嶆垨鑰卝pg鏁堟灉浼氭洿濂戒簺銆?br />鍏堢湅涓嬭漿鎹㈢殑緇撴灉銆?br />杞崲鍓嶏細
杞崲鐨勫瓧絎︾敾錛?br />

緇撴灉姣旇緝綺楃硻錛屼絾榪樺彲浠ユ帴鍙楋紝鎴戞兂濡傛灉鏄?4浣峛mp浼氬ソ寰堝銆傛湁鏃墮棿鐨勮瘽琛ュ厖涓涓嬨?br />榪欓噷鏄唬鐮侊細 1 /*
 2  * =====================================================================================
 3  *       Filename:  ConvertBmpToAscii.cpp
 4  *    Description:  convert a 256bmp file to ascii-file
 5  *
 6  *        Version:  1.0
 7  *        Created:  03/09/2013 05:46:16 PM
 8  *
 9  *         Author:  zhy (), izualzhy@163.com
10  * =====================================================================================
11  */
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include "Defs.h"
16 
17 int GetGrayFromRGB(RGBQuad color)
18 {
19     return color.rgbRed*0.299 + color.rgbGreen*0.587 + color.rgbBlue*0.114;
20 }
21 
22 char GetCharFromGray(int gray)
23 {
24     if (gray > 0.9 && gray <=1.0)
25     {
26         return '#';
27     } else if (gray > 0.7) {
28         return '@';
29     } else if (gray > 0.4) {
30         return '~';
31     } else if (gray > 0.2) {
32         return '\'';
33     } else {
34         return ' ';
35     }
36 }
37 
38 int main(int argc, char* argv[])
39 {
40     if (argc < 2)
41         return -1;
42 
43     FILE* fp = fopen(argv[1], "r");
44     if (!fp)
45         return -1;
46 
47     BitMapFileHeader bmfHeader;
48     fread(&bmfHeader, sizeof(bmfHeader), 1, fp);
49 
50     BitMapInfoHeader bmiHeader;
51     fread(&bmiHeader, sizeof(bmiHeader), 1, fp);
52 
53     RGBQuad colorTable[256];
54     fread(colorTable, sizeof(RGBQuad), 256, fp);
55 
56     int width = bmiHeader.biWidth;
57     width = (width*bmiHeader.biBitCount + 31)/8;
58     width = width/4*4;
59     int height = bmiHeader.biHeight;
60 
61     unsigned char* dataImage = (unsigned char*)malloc(width*height*sizeof(unsigned char));
62     memset(dataImage, 0, width*height);
63     fread(dataImage, 1, width*height, fp);
64     char* dataAscii = (char*)malloc(width*height*sizeof(char));
65     memset(dataAscii, ' ', width*height);
66     for (int i=0; i<width; ++i)
67         for (int j=height-1; j>=0; --j)
68         {
69             int gray = GetGrayFromRGB(colorTable[dataImage[j*width + i]]);
70             dataAscii[(height - 1 - j)*width + i] = GetCharFromGray(gray);
71         }
72 
73     fclose(fp);
74 
75     fp = fopen("demo.txt", "w");
76     if (!fp)
77         return -1;
78 
79     for (int j=0; j<height; j+=10)
80     {
81         for (int i=0; i<width; i+=10)
82         {
83             fwrite(dataAscii + j*width + i, 1, 1, fp);
84         }
85         fwrite("\n", 1, sizeof("\n"), fp);
86     }
87     fclose(fp);
88     free(dataImage);
89     free(dataAscii);
90 
91     return 0;
92 }
93 


izualzhy 2013-03-09 23:38 鍙戣〃璇勮
]]>
BMP鏍煎紡瀛︿範涔嬪垱寤篵mp鏂囦歡http://m.shnenglu.com/izualzhy/archive/2013/03/09/198317.htmlizualzhyizualzhySat, 09 Mar 2013 09:22:00 GMThttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198317.htmlhttp://m.shnenglu.com/izualzhy/comments/198317.htmlhttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198317.html#Feedback0http://m.shnenglu.com/izualzhy/comments/commentRss/198317.htmlhttp://m.shnenglu.com/izualzhy/services/trackbacks/198317.html鎺ヤ笂綃囷紝鏃㈢劧棰滆壊琛ㄥ彲浠ュ緱鍒幫紝bmp鐨勬枃浠舵牸寮忓凡緇忓緢娓呮浜嗭紝鑳藉惁鑷繁鍒涘緩bmp鏂囦歡鍛紵

榪樻槸浠?56鑹瞓mp涓轟緥.

絳旀鏄彲浠ョ殑錛岃繖鏄▼搴忕敓鎴愮殑涓涓畝鍗曠殑bmp錛?/p>

demo

鏍規(guī)嵁涔嬪墠鐨勯鑹茶〃錛屽彲浠ュ緱鍒皉ed,green,blue鍍忕礌瀵瑰簲鐨刬ndex,鍙鍦ㄤ綅鍥炬暟鎹尯鍐欎笂璇ュ唴瀹瑰氨濂戒簡銆?/p>

娉ㄦ剰浣嶅浘鏁版嵁鐨勬柟鍚戞槸浠庡乏鍒板彸浠庝笅鑷充笂銆?/p>

Code Snippet
  1. /*
  2. * =====================================================================================
  3. *       Filename:  CreateBMPFile.cpp
  4. *    Description:  demos of creating 256BMP file
  5. *
  6. *        Version:  1.0
  7. *        Created:  03/09/2013 03:44:13 PM
  8. *
  9. *         Author:  zhy (), izualzhy@163.com
  10. * =====================================================================================
  11. */
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "Defs.h"
  16.  
  17. int main()
  18. {
  19.     const int width = 200;
  20.     const int height = 300;
  21.     const int bitCount = 8;
  22.  
  23.     int realWidth = (width * bitCount + 31)/8;
  24.     realWidth = realWidth/4*4;
  25.     const int dataSize = realWidth * height;
  26.  
  27.     BitMapFileHeader bmfHeader;
  28.     memset(&bmfHeader, 0, sizeof(bmfHeader));
  29.     bmfHeader.bfType = 0x4d42;
  30.     bmfHeader.bfOffBits = sizeof(BitMapFileHeader) + sizeof(BitMapInfoHeader) + sizeof(RGBQuad)*256;
  31.     bmfHeader.bfSize = bmfHeader.bfOffBits + dataSize;
  32.  
  33.     BitMapInfoHeader bmiHeader;
  34.     memset(&bmiHeader, 0, sizeof(bmiHeader));
  35.     bmiHeader.biSize = sizeof(BitMapInfoHeader);
  36.     bmiHeader.biWidth = width;
  37.     bmiHeader.biHeight = height;
  38.     bmiHeader.biPlanes = 1;
  39.     bmiHeader.biBitCount = bitCount;
  40.     bmiHeader.biSizeImage = dataSize;
  41.  
  42.     FILE* fpIn = fopen("3.bmp", "r");//3.bmp鏄箣鍓嶆祴璇曠敤鐨勬枃浠訛紝256鑹瞓mp
  43.     if (!fpIn)
  44.         return -1;
  45.  
  46.     RGBQuad colorTables[256];
  47.     fseek(fpIn, 0x36, SEEK_SET);
  48.     fread(colorTables, sizeof(RGBQuad), 256, fpIn);
  49.     fclose(fpIn);
  50.  
  51.     unsigned char* imageData = (unsigned char*)malloc(dataSize*sizeof(unsigned char));
  52.     if (!imageData)
  53.         return -1;
  54.  
  55.     memset(imageData, 0, dataSize);
  56.     for (int i=0; i<realWidth; ++i)
  57.     {
  58.         for (int j=0; j<=20; ++j)
  59.         {
  60.             imageData[j*realWidth + i] = 0xff;//white
  61.         }
  62.  
  63.         for (int j=50; j<=100; ++j)
  64.         {
  65.             imageData[j*realWidth + i] = 0xfc;//blue
  66.         }
  67.  
  68.         for (int j=150; j<=180; ++j)
  69.         {
  70.             imageData[j*realWidth + i] = 0xfa;//green
  71.         }
  72.  
  73.         for (int j=220; j<300; ++j)
  74.         {
  75.             imageData[j*realWidth + i] = 0xf9;//red
  76.         }
  77.     }
  78.  
  79.     FILE* fpOut = fopen("demo.bmp", "w");
  80.     if (!fpOut)
  81.         return -1;
  82.  
  83.     fwrite(&bmfHeader, sizeof(bmfHeader), 1, fpOut);
  84.     fwrite(&bmiHeader, sizeof(bmiHeader), 1, fpOut);
  85.     fwrite(colorTables, sizeof(RGBQuad), 256, fpOut);
  86.     fwrite(imageData, 1, dataSize, fpOut);
  87.     fclose(fpOut);
    free(imageData);
  88. }

璇ヤ唬鐮佷細鐢熸垚涓婅堪bmp鏂囦歡銆?/p>

濡傛灉浣犵湅浜嗗墠闈㈢殑鏂囩珷錛屽氨鍒棶鎴?.bmp鍝噷鐨刕_^

鍥犱負鏁版嵁鏂瑰悜浠庝笂鍒頒笅錛屽洜姝や粠涓嬪埌涓婁緷嬈′負white, blue, green, red銆?/p>

鏃㈢劧鏁版嵁鍙互榪欎箞鍐欏叆錛屾帴涓嬫潵鐨勫氨鍙互鑷繁鐜╁暒銆?/p>

姣斿鍐欏叆鐨勪唬鐮佹敼鎴愪簡榪欎釜鏍峰瓙錛?/p>

Code Snippet
  1. int i = 0;
  2.   while (i++ < 100)
  3.   {
  4.       int randX = rand()%realWidth;
  5.       int randY = rand()%height;
  6.       int randColorIndex = rand()%256;
  7.       const int range = 15;
  8.  
  9.       int minX = randX - range;
  10.       minX = minX > 0 ? minX : 0;
  11.       int minY = randY - range;
  12.       minY = minY > 0 ? minY : 0;
  13.       int maxX = randX + range;
  14.       maxX = maxX > realWidth ? realWidth : maxX;
  15.       int maxY = randY + range;
  16.       maxY = maxY > height ? height : maxY;
  17.  
  18.       printf("%d,%d,%d,%d\n",minX, maxX, minY, maxY);
  19.       for (int i=minX; i<maxX; ++i)
  20.           for (int j=minY; j<maxY; ++j)
  21.           {
  22.               imageData[j*realWidth + i] = randColorIndex;
  23.           }
  24.   }

闅忔満鍙栫偣錛屼互璇ョ偣涓轟腑蹇冪殑鐭╁艦闅忔満濉厖棰滆壊銆傚氨鎴愪簡榪欎釜鏍峰瓙錛?/p>

demo

鏄笉鏄緢濂界帺錛熺粯鍒剁洿綰匡紝鍦嗗艦搴旇灝卞緢瀹規(guī)槗浜嗐?/p>

izualzhy 2013-03-09 17:22 鍙戣〃璇勮
]]>
BMP鏍煎紡瀛︿範涔嬫彁鍙栭鑹茶〃http://m.shnenglu.com/izualzhy/archive/2013/03/09/198315.htmlizualzhyizualzhySat, 09 Mar 2013 07:52:00 GMThttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198315.htmlhttp://m.shnenglu.com/izualzhy/comments/198315.htmlhttp://m.shnenglu.com/izualzhy/archive/2013/03/09/198315.html#Feedback0http://m.shnenglu.com/izualzhy/comments/commentRss/198315.htmlhttp://m.shnenglu.com/izualzhy/services/trackbacks/198315.html鎸夌収浠庣綉涓婃煡鎵劇殑璧勬枡bmp鏍煎紡鐨勯鑹茶〃鏄笉鍥哄畾鐨勶紝鐨勭‘濡傛錛屾垜嫻嬭瘯浜嗗嚑涓猙mp錛岄鑹茶〃鍚勪笉鐩稿悓銆?/p>

涓嶈繃鐢眞indows鐢誨浘紼嬪簭鐢熸垚鐨?56鑹茬殑bmp璇曢獙鏃訛紝鍙戠幇棰滆壊琛ㄤ竴鐩寸浉鍚岋紝鐢ㄦ潵浣滀負鑷繁鐢熸垚bmp鏂囦歡鐨勯鑹茶〃妯$増涓嶉敊銆?/p>

浠g爜錛?/p>

Code Snippet
  1. /*
  2. * =====================================================================================
  3. *       Filename:  PrintColorTable.cpp
  4. *    Description:  Print ColorTable Of Bmp Files
  5. *
  6. *        Version:  1.0
  7. *        Created:  03/09/2013 02:56:28 PM
  8. *
  9. *         Author:  zhy (), izualzhy@163.com
  10. * =====================================================================================
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <math.h>
  16. #include "Defs.h"
  17. using namespace std;
  18.  
  19. int main(int argc, char* argv[])
  20. {
  21.     if (argc < 2)
  22.         return -1;
  23.  
  24.     FILE* fp = fopen(argv[1], "r");
  25.     if (!fp)
  26.         return -1;
  27.  
  28.     BitMapFileHeader bmfHeader;
  29.     fread(&bmfHeader, sizeof(bmfHeader), 1, fp);
  30.  
  31.     BitMapInfoHeader bmiHeader;
  32.     fread(&bmiHeader, sizeof(bmiHeader), 1, fp);
  33.  
  34.     RGBQuad* colorTable = NULL;
  35.     const int tableCount = pow(2, bmiHeader.biBitCount);
  36.     switch (bmiHeader.biBitCount)
  37.     {
  38.         case 1:
  39.         case 4:
  40.         case 8:
  41.             colorTable = (RGBQuad*)malloc(tableCount*sizeof(RGBQuad));
  42.             break;
  43.         case 24:
  44.             //no colorTable;
  45.             printf("No ColorTable For 24bits-bmp\n");
  46.             return 0;
  47.         default:
  48.             printf("unrecoginzed bitsCount\n");
  49.             return 0;
  50.     }
  51.  
  52.     if (!colorTable)
  53.     {
  54.         printf("malloc error!\n");
  55.         return -1;
  56.     }
  57.  
  58.     fread(colorTable, sizeof(RGBQuad), tableCount, fp);
  59.     for (int i=0; i<tableCount; ++i)
  60.     {
  61.         printf("%02x %02x %02x %02x\n", colorTable[i].rgbBlue, colorTable[i].rgbGreen, colorTable[i].rgbRed, colorTable[i].rgbReserved);
  62.     }
  63.  free(colorTable);
  64.     return 0;
  65. }

 

鍙互鐢ㄦ潵鎵撳嵃鍗曡壊浣嶅浘錛?6鑹蹭綅鍥撅紝256鑹蹭綅鍥劇殑棰滆壊琛紝榪涗竴姝ユ瘮杈冪浉鍚屼綅涓嶅悓bmp鐨勯鑹茶〃鐨勫尯鍒?/p>

izualzhy 2013-03-09 15:52 鍙戣〃璇勮
]]>
久久综合综合久久狠狠狠97色88| 久久午夜伦鲁片免费无码| 国产精品成人99久久久久| 国产福利电影一区二区三区,免费久久久久久久精 | 香蕉aa三级久久毛片| 久久久久久精品免费看SSS | 日韩AV毛片精品久久久| 日产精品99久久久久久| 精品一久久香蕉国产线看播放| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久精品国产亚洲AV忘忧草18| 精品人妻久久久久久888| 亚洲国产精品一区二区三区久久| 奇米影视7777久久精品| 亚洲欧洲久久av| 国产福利电影一区二区三区久久久久成人精品综合 | 久久午夜福利无码1000合集| 精品国际久久久久999波多野| 日本久久中文字幕| 国产99久久久久久免费看| 少妇精品久久久一区二区三区| 久久久久国产精品三级网| 久久99久久99精品免视看动漫| 亚洲精品国精品久久99热| 久久99精品国产99久久6| 韩国三级大全久久网站| 久久精品www人人爽人人| 国产精品久久新婚兰兰| 伊人精品久久久久7777| 久久人人爽人爽人人爽av| 精品久久综合1区2区3区激情| 久久精品国产精品国产精品污| 久久亚洲春色中文字幕久久久 | 日本久久久精品中文字幕| 狠狠狠色丁香婷婷综合久久五月| 久久香蕉国产线看观看精品yw| 综合网日日天干夜夜久久| 久久夜色精品国产亚洲| 伊人久久精品无码av一区| 欧美精品乱码99久久蜜桃| 久久精品国产免费观看|