reset password
Author Message
kevinmowers@yahoo.com
Posts: 49
Posted 14:12 Mar 10, 2015 |

I don't know why my .ppm images are missing pixels. The number of color channels should equal width * height * 3, but when I display the size of the array, I'm off by thousands of color channels. 

I'm using a while(istream >> character). Is there any reason why I would be missing characters? Or is this technique wrong?

I attached a screen shot what the ppm looks like.

303496263
Posts: 68
Posted 15:17 Mar 10, 2015 |

The extraction operator >> works with formatted data only and skips whitespaces, newlines, and tab. It seems like that is why you are not getting all the characters into your array.

Why don't you use the "read" method of the istream to read all the data into your array? 

Like this istream.read(char *s, streamsize n) where s is the pointer to your character array where the extracted characters are to be stored and n is the number of the characters to be extracted from istream.

kevinmowers@yahoo.com
Posts: 49
Posted 14:17 Mar 11, 2015 |

I was doing it completely wrong lol. I was supposed to use the read function lol

thank you 303496263

303496263
Posts: 68
Posted 16:17 Mar 11, 2015 |
kevinmowers@yahoo.com wrote:

I was doing it completely wrong lol. I was supposed to use the read function lol

thank you 303496263

You are very welcome :)