為什么代碼除錯不出來 用的vs2019
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<Windows.h>
//右鍵點擊專案的屬性,在配置屬性、c/c++、代碼生成、結構成員對齊
//選擇 "1位元組"
struct bmpFileHeader
{
short bfType; //0x00起始偏移
int bfSize; //0x02 //檔案大小
int bfReserve; //0x06
int bfoffBits; //0x0a
int bitSize; //0x0e 為40
int biWidth; //0x12 ****//位圖寬
int biHeight; //0x16 *****//位圖高
short biPlanes; //0x1a 為1
short biBitCount; //0x1c ****//采用顏色位數,可以是1,2,4,8,16,24,新的可以是32
int biCompression; //0x1e //壓縮方式,可以是0,1,2,其中0表示不壓縮
int biSizeImage; //0x22 //實際位圖資料占用的位元組數
int biXPlosPerMeter;//0x26
int biYPlosPerMeter;//0x2a
int biClrUsed; //0x2e
int biClrImportant; //0x32
} header;
int comp_linesize(struct bmpFileHeader* pheader)
{
int sum = 0;
sum = pheader->biWidth;
sum *= 3;
if (sum % 4 == 0) return sum;
if (sum % 4 != 0)sum += 4 - (sum % 4); return sum;
}
void printMsg(struct bmpFileHeader* pheader)
{
printf("圖象寬:%d\n影像高:%d\n%d掃描行大小:\n", header.biWidth, header.biHeight, comp_linesize(&header));
}
int main()
{
printf("請輸入檔案名:\n");
char file1[100];
scanf_s("%s", file1); FILE* fpl;
fpl = fopen(file1, "rb");
if (fpl == NULL)
{ printf("%s打開失敗", file1); return 0;
}
fread(&header, sizeof(struct bmpFileHeader), 1, fpl); int linesize = comp_linesize(&header);
int txsize = linesize * header.biHeight;
char* bmpbody = (char*)malloc(txsize);
fread(bmpbody, txsize, 1, fpl); printMsg(&header); fclose(fpl);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/239342.html
標籤:C語言
上一篇:C#表單form1中用control.add加了一個picturebox到form2,在form2中在哪里可以給這個picturebox撰寫內容?
