Open FarzanehCS opened 2 years ago
First things first, there is a limit to how much a line of a ppm file can hold, which is about 70 characters. This is seen in the bottom of the example showcasing P3. So, when writing your rgb values in, make sure the add a new line in from time to time, or else it wont read the rest properly. Secondly, it seems like your not looping through all your data. Make sure your looping through every single element in the data variable, and get the right amount of data depending on number of channels.
I resolved this. I was not getting the correct indexes while looping.
Hello, When I compile the code and get the output images (which are written by the
write_ppm
function), theppm
files generated look strange! Like forwrite_ppm("rgb.ppm",rgb,width,height,3);
I get this ppm file:This is the simplest case where I create the rgb image by
rgba_to_rgb(rgba,width,height,rgb);
and then callwrite_ppm
, but not sure why I get this. Here is what I have done: When we turn thergba
torgb
, we only keep the rgb values, i.e. the first, second, and third values ofrgba
pixels. Also for writing the files, I followed this: https://en.wikipedia.org/wiki/Netpbm#PPM_exampleAny help is much appreciated.