這裡記錄了我的點點滴滴和各種四面八方的數學證明,還有我最喜歡的程式語言-VB!
我要留言
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;
}
'發送端Dim Https Set Https = Server.Createobject("MSXML2.XMLHTTP")Https.Open "POST" , "http://127.0.0.1/testpost/response.asp" , False ...《 詳全文 》
模組程式碼: Imports System.NetImports System.Net.NetworkInformationImports System.Net.SocketsImports System.Text.EncodingPublic Module FileTransfer Private Cons ...《 詳全文 》