QuestionQuestion

Write a simple program that is able to read PPM image files.
• Input : PPM filename – the file will be used for file open in the program.
• Output : 3-dimensional array integer [][][] – width BY height BY 3 (RGB) :
Display (0, 0) --> (100, 101, 102) (0, 1) --> (100, 102, 95) (0, 2) --> (45, 104, 100) . . . (1, 0) --> (100, 99, 104) . . .
• Others : This program will be used for sub-program (class, object or function) of another program.
Do not specify the file format (ASCII, or BINARY), nor size of image.
The program should be able to recognize different magic number (P3 and P6).
In case of ‘P6’, return an error message.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

/*
* File:   ppmreader.cpp
*
*
*
*/

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>
#include<sstream>
using namespace std;

/*
*
*/

string <rim(std::string &s) {
       s.erase(s.begin(), find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
       return s;
}

string &rtrim(std::string &s) {
       s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
       return s;
}

string &trim(std::string &s) {
       return ltrim(rtrim(s));
}

int main(int argc, char** argv) {

    vector<string> v;
    string sLine = "";
    ifstream infile;...

By purchasing this solution you'll be able to access the following files:
solution.zip.

$20.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available 3D Graphics Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats