。。
cf.Read(&bmfh,sizeof(bmfh)); //读取文件头
cf.Read(&bmih,sizeof(bmih)); //读取文件信息
TRACE("\n%d\n",bmih.biSizeImage);
rgb = new RGBTRIPLE[bmih.biWidth*bmih.biHeight]; //分配内存
cf.SeekToBegin();
cf.Seek(54,CFile::begin); //读取文件数据
if (cf.GetLength()>64*1024)
{
cf.ReadHuge(rgb,bmih.biWidth*bmih.biHeight*3);//
}
else
{
cf.Read(rgb,bmih.biWidth*bmih.biHeight);
}
//将象素值保存在三维数组
short array[180][230][3];
for (int i=0; i<(bmih.biHeight/2);i++)
{
for (int j=0; j<(bmih.biWidth/2); j++)
{
// pDC->SetPixel(j,bmih.biHeight-i,
// RGB(rgb[i*bmih.biWidth+j].rgbtRed,
// rgb[i*bmih.biWidth+j].rgbtGreen,
// rgb[i*bmih.biWidth+j].rgbtBlue)); array[i][j][0]=rgb[i*bmih.biWidth+j].rgbtRed;
array[i][j][1]=rgb[i*bmih.biWidth+j].rgbtGreen;
array[i][j][2]=rgb[i*bmih.biWidth+j].rgbtBlue;
}
} for(int h=0;h<(bmih.biHeight/2);i++)
{
for(int w=0;w<(bmih.biWidth/bmih.biHeight)*h-h;w++)
{
pDC->SetPixel(w,(bmih.biHeight)/2-h,
RGB(array[h][w][0],
array[h][w][1],
array[h][w][2]));
}
}
for(int a=0;a<180;a++)
{
for(int b=0;b<230;b++)
{
for(int c=0;c<3;c++)
{
array[a][b][c]=0;
}
}
}
cf.Close();//关闭文件
delete rgb;//释放内存 ReleaseDC(pDC);
}
cf.Read(&bmfh,sizeof(bmfh)); //读取文件头
cf.Read(&bmih,sizeof(bmih)); //读取文件信息
TRACE("\n%d\n",bmih.biSizeImage);
rgb = new RGBTRIPLE[bmih.biWidth*bmih.biHeight]; //分配内存
cf.SeekToBegin();
cf.Seek(54,CFile::begin); //读取文件数据
if (cf.GetLength()>64*1024)
{
cf.ReadHuge(rgb,bmih.biWidth*bmih.biHeight*3);//
}
else
{
cf.Read(rgb,bmih.biWidth*bmih.biHeight);
}
//将象素值保存在三维数组
short array[180][230][3];
for (int i=0; i<(bmih.biHeight/2);i++)
{
for (int j=0; j<(bmih.biWidth/2); j++)
{
// pDC->SetPixel(j,bmih.biHeight-i,
// RGB(rgb[i*bmih.biWidth+j].rgbtRed,
// rgb[i*bmih.biWidth+j].rgbtGreen,
// rgb[i*bmih.biWidth+j].rgbtBlue)); array[i][j][0]=rgb[i*bmih.biWidth+j].rgbtRed;
array[i][j][1]=rgb[i*bmih.biWidth+j].rgbtGreen;
array[i][j][2]=rgb[i*bmih.biWidth+j].rgbtBlue;
}
} for(int h=0;h<(bmih.biHeight/2);i++)
{
for(int w=0;w<(bmih.biWidth/bmih.biHeight)*h-h;w++)
{
pDC->SetPixel(w,(bmih.biHeight)/2-h,
RGB(array[h][w][0],
array[h][w][1],
array[h][w][2]));
}
}
for(int a=0;a<180;a++)
{
for(int b=0;b<230;b++)
{
for(int c=0;c<3;c++)
{
array[a][b][c]=0;
}
}
}
cf.Close();//关闭文件
delete rgb;//释放内存 ReleaseDC(pDC);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货