0
我遇到的问题是我的PPM图像太小,当我想在窗口中显示它时(没有缩放,可用缩放,并且必须将图像保存在磁盘),我只是使用一个简单的函数来升级像素(或者只是将更多次写入文件)。但在此之后,图像变得非常混乱(如截图所示)并且分辨率错误。过去4小时我尝试了很多东西,但没有任何效果。 有没有解决这个问题,或者我只是错过了一些显而易见的事情,或者做了很多错误的事情? 我在C++ cli Windows窗体(VS)中使用PictureBox,但在图像查看器(WinExplorer,IrfanView)中显示了相同的内容。放大的PPM图像(无滤波)
继承人主要代码,尺寸是尺寸(图像是方形),颜色只是表示它是否想要变为颜色,像素尺寸是否会放大像素。 此外,我提供全程的Git代码Here
int sizemult = size;
if (color)
sizemult *= 3; //3 values of RGB
std::fstream file;
file.open("temp.ppm", std::ios::trunc | std::ios::out);
if (color)
file << "P3" << std::endl;
else
file << "P2" << std::endl;
file << size*pixelsize << " " << size*pixelsize << std::endl;
file << 256 << std::endl;
for (auto i = 0; i < size; i++) {
for (auto h = 0; h < pixelsize; h++) {
for (auto k = 0; k < size*sizemult; k++) {
for (auto j = 0; j < pixelsize; j++) {
file << table[i*size+k] << " ";
}
}
file << std::endl;
}
}
file.close();
}