karansher / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
1 stars 0 forks source link

Confused by write_ppm #42

Closed Tahmeem closed 1 year ago

Tahmeem commented 1 year ago

I'm having a issue where I don't understand why the values are special characters rather than ints and so I think my ppm files are being generated with the wrong thing. write_ppm is used in the other parts so if someone could explain why its these chars instead of ints in the vectors that would be helpful. Also Im guessing we open the ppm files in an image viewer to test out the code?

RamDaj commented 1 year ago

Personally I use GIMP to open the image files, a similar image modification software should do the trick

Ming-Yeung-Alfred-Meng commented 1 year ago

This is my guess, I could be wrong.

the vectors store unsigned chars, so the strings of 1s and 0s stored are interpreted as characters when you write them to the file. Maybe try to do something so that these strings are interpreted as integers.

abhimadan commented 1 year ago

@Ming-Yeung-Alfred-Meng is correct - unsigned chars are interpreted as ASCII characters and not numbers when printed, so you need to cast them to ints. Also, GIMP is a great program for viewing ppm files.