-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Description

Why my image looks like that? By the way, this is not the first time I encountered situation like that.
I printed out the result (before saving) which is correct.

The above file (I only print first 10 rgb values) indicates that from line 311 to line 341 is constantly with color 59, -84, -42 however in the first screenshot we can see something else in this range.
I also did another expriments: read the ppm file and print them on the console.

I think the codes crashed halfway. Down below, 971547 is the counter of CHARs. I did the math (also we can see from the pic) 971547 is at H:316, W795. If finish well, the counter should be 1024 x 747 x 3 = 2294784.
I will also upload the codes.
// stdafx.cpp : source file that includes just the standard includes
// CPPTEST2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
int main123()
{
std::ifstream infile("out_phong.ppm");
if (!infile.is_open()) {
std::cerr << "ERR\n";
return 1;
}
std::string line;
while (std::getline(infile, line)) {
int char_num = 0;
for (char c : line) {
//if (char_num % (1024 * 3) == 0)
//{
// std::cout << std::endl << (char_num/3072) << std::endl;
//}
if (char_num > 970752)
{
std::cout << (int)c << ' ';
}
else
{
if (char_num % 3072 == 0)
{
std::cout << char_num / 3072 << std::endl;
}
if (char_num % (3072) < 30)
{
std::cout << (int)c << ' ';
//std::cout << std::endl;
}
if (char_num % (3072) == 31)
{
std::cout << std::endl;
}
}
//std::cout << c;
char_num++;
}
std::cout << std::endl << (char_num) << std::endl;
std::cout << std::endl;
}
infile.close();
printf("sdadasds\n");
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels