L
lizheng
Unregistered / Unconfirmed
GUEST, unregistred user!
int i;
int *p = NULL
//必须为int,因为fgetc返回值为int,若定义为char,会有问题出现
FILE *bmpfp, *outfp;
if (OpenDialog1->Execute())
{
for (i = 0
i < OpenDialog1->Files->Count
i ++)
{
bmpfp = fopen(OpenDialog1->Files->Strings.c_str(), "rb");
if (bmpfp == NULL)
return;
if (fread((char*)&FileHeader, 1, sizeof(BITMAPFILEHEADER), bmpfp) != sizeof(BITMAPFILEHEADER))//sizeof(BITMAPFILEHEADER)=14
ShowMessage("FileHeader Open Failed");
if (fread((char*)&BmpInfoHeader, 1, sizeof(BITMAPINFOHEADER), bmpfp) != sizeof(BITMAPINFOHEADER))//sizeof(BITMAPINFOHEADER)=40
ShowMessage("BmpInfoHeader Open Failed");
bytes = FileHeader.bfSize
//width * BmpInfoHeader.biBitCount;
fseek(bmpfp, 54, SEEK_SET);
if ((p = (int *)malloc(bytes - 53)) == NULL)
return;
while((*(p + i) = fgetc(bmpfp)) != EOF) i ++;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~如果没有这一句,后面的错误就不会出现
fclose(bmpfp);
if (BmpInfoHeader.biBitCount != 1 &&
BmpInfoHeader.biBitCount != 4 &&
BmpInfoHeader.biBitCount != 8)
{
ShowMessage(OpenDialog1->FileName + "is not monochrome or 16 or 256 BMP file.");
if (BmpInfoHeader.biCompression == 0)
Image1->Picture->LoadFromFile(OpenDialog1->FileName);
return;
}
if (SaveDialog1->Execute())
~~~~~~~~~~~~~~~~~~~~~~~~~~出错!
outfp = fopen(SaveDialog1->FileName.c_str(), "wb");
......
int *p = NULL
//必须为int,因为fgetc返回值为int,若定义为char,会有问题出现
FILE *bmpfp, *outfp;
if (OpenDialog1->Execute())
{
for (i = 0
i < OpenDialog1->Files->Count
i ++)
{
bmpfp = fopen(OpenDialog1->Files->Strings.c_str(), "rb");
if (bmpfp == NULL)
return;
if (fread((char*)&FileHeader, 1, sizeof(BITMAPFILEHEADER), bmpfp) != sizeof(BITMAPFILEHEADER))//sizeof(BITMAPFILEHEADER)=14
ShowMessage("FileHeader Open Failed");
if (fread((char*)&BmpInfoHeader, 1, sizeof(BITMAPINFOHEADER), bmpfp) != sizeof(BITMAPINFOHEADER))//sizeof(BITMAPINFOHEADER)=40
ShowMessage("BmpInfoHeader Open Failed");
bytes = FileHeader.bfSize
//width * BmpInfoHeader.biBitCount;
fseek(bmpfp, 54, SEEK_SET);
if ((p = (int *)malloc(bytes - 53)) == NULL)
return;
while((*(p + i) = fgetc(bmpfp)) != EOF) i ++;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~如果没有这一句,后面的错误就不会出现
fclose(bmpfp);
if (BmpInfoHeader.biBitCount != 1 &&
BmpInfoHeader.biBitCount != 4 &&
BmpInfoHeader.biBitCount != 8)
{
ShowMessage(OpenDialog1->FileName + "is not monochrome or 16 or 256 BMP file.");
if (BmpInfoHeader.biCompression == 0)
Image1->Picture->LoadFromFile(OpenDialog1->FileName);
return;
}
if (SaveDialog1->Execute())
~~~~~~~~~~~~~~~~~~~~~~~~~~出错!
outfp = fopen(SaveDialog1->FileName.c_str(), "wb");
......