會員登入 新使用者?立即註冊

這裡記錄了我的點點滴滴和各種四面八方的數學證明,還有我最喜歡的程式語言-VB!

關閉
你好,歡迎參觀我的部落格! 我要留言

最新文章

分類: C#
2009/08/01 10:42

int read_bmp(char *filename, unsigned char ***bmp, int *height, int *width)
{
 long *hed;
 int i, j, k, w;

 unsigned char head[1079], l, mod, *tmp_buf;
 FILE *f;
 hed = (long *) &head[2];

 if ((f = fopen(filename, "rb")) == NULL) return 1;
 if (fread(head, 1, 54, f) != 54) return 2;
 if (head[0] != 'B' || head[1] != 'M') return 3; // BMP Head
 fseek(f, 0, SEEK_END);
 if (ftell(f) - hed[0]) return 4; // File size != internal record
 mod = head[28]; // Bit / pixel
 if (mod != 1 && mod != 8) return 5;
 if (head[30]) return 6; // Bitmap compression method
 *width = hed[4], *height = hed[5];
 if ((tmp_buf = (unsigned char *) malloc(hed[8])) == NULL) return 7;
 if ( !(*bmp = (unsigned char **)malloc(*height *sizeof(**bmp)))) return 8;
 if ( (**bmp = (unsigned char *) malloc(*width * *height + 7)) == NULL) return 9;
 fseek(f, hed[2], SEEK_SET); // To bmp data start
 if (fread(tmp_buf, 1, (size_t)hed[8]-1, f) != hed[8]-1) return 10; // Read error
 for (w=i=0; i<*height; i++, w+=*width) // Calculate index for speedup
 (*bmp)[i] = &(**bmp)[w];
 if (mod == 1)
 {
  w = (int) ( ((*width-1) >> 5) +1 ) << 2;
  for (i=(int)(*height-1); i>=0; i--)
  {
   for (j=0; j<*width-7; j+=8)
   {
    l = tmp_buf[i*w + (j>>3)];
    for (k=0; k<8; k++)
    {
     (**bmp)[(*height-i-1)**width + j + k] = l & 128 ? 0 : 1;
     l <<= 1;
    }
   }
   l = tmp_buf[i*w + (j>>3)];
   for (k=0; k<(*width&7); k++)
   { 
    (**bmp)[(*height-i-1)**width + j + k] = l & 128 ? 0 : 1;
    l <<= 1;
   }
  }
 }
 else if (mod == 8)
 {
  w = (int) (((*width-1)>>2) +1) << 2;
  for (i=(int)(*height-1); i>=0; i--)
  {
    k = *height - i -1;
   for (j=0; j<*width; j++)
    (*bmp)[k][j] = tmp_buf[i*w + j];
  }
  }
 free(tmp_buf);
 if (fclose(f)) return 11;
 return 0;
}

回應(0) 引用(0)
分類: ASP
2009/06/07 11:33

 '發送端Dim Https Set Https = Server.Createobject("MSXML2.XMLHTTP")Https.Open  "POST" , "http://127.0.0.1/testpost/response.asp" , False ...《 詳全文

回應(0) 引用(0)
分類: VB2005
2009/03/15 20:13

模組程式碼: Imports System.NetImports System.Net.NetworkInformationImports System.Net.SocketsImports System.Text.EncodingPublic Module FileTransfer    Private Cons ...《 詳全文

回應(0) 引用(0)
分類: VB2005
2009/02/19 11:52

''' <summary>''' 取得像素值。''' </summary>''' <param name="X">X 軸。</param>''' <p ...《 詳全文

回應(0) 引用(0)
分類: VB6.0
2009/02/07 22:16

程式的步驟 執行 Visual Basic for Windows,或在 [檔案] 功能表上選擇新的專案 (ALT、 F、 N) 如果 Visual Basic for Windows 已在執行。 根據預設,會建立 Form1。 將兩個名為 Pict ...《 詳全文

回應(0) 引用(0)

BloggAd

    第一屆教育部落格大賽

版主的話

    姓名:灰原哀
    組織代號:80123
    歡迎來到灰原哀之往事♀!

更新日期

2009/08/01 10:42
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30  

搜尋

雅虎資訊 版權所有 © 2009 Yahoo! Taiwan All Rights Reserved
「本服務設有管理員」 服務條款 隱私權政策