因此,尽管有人可以帮助我,但我正确地调用了该类,但我仍然收到此错误。
void PPM::sepiaFilter( PPM& dst ) const {
dst.setWidth( this->getWidth( ) );
dst.setHeight( this->getHeight( ) );
dst.setMaxColorValue( this->getMaxColorValue( ) );
double red = 0;
double green = 0;
double blue = 0;
for ( int y = 0; y <= this->getHeight( ); y++ ) {
for ( int x = 0; x <= this->getWidth( ); x++ ) {
red = this->getChannel( y, x, 0 );
green = this->getChannel( y, x, 1 );
blue = this->getChannel( y, x, 2 );
double new_red = 0.393 * red + 0.769 * green + 0.189 * blue;
double new_green = 0.349 * red + 0.686 * green + 0.168 * blue;
double new_blue = 0.272 * red + 0.534 * green + 0.131 * blue;
if ( new_red > this->getMaxColorValue( ) ) {
dst.setChannel( y, x, 0, this->getMaxColorValue( ) );
}
if ( new_green > this->getMaxColorValue( ) ) {
dst.setChannel( y, x, 1, this->getMaxColorValue( ) );
}
if ( new_blue > this->getMaxColorValue( ) ) {
dst.setChannel( y, x, 2, this->getMaxColorValue( ) );
}
dst.setChannel( y, x, 0, int ( new_red ) );
dst.setChannel( y, x, 1, int ( new_green ) );
dst.setChannel( y, x, 2, int ( new_blue ) );
}
}
}
即使一切正常,我仍然会收到此错误,无论我做什么。我做了很多更改,以使它不会引发错误,而我只会继续引发相同的错误。如果有人可以帮助我找到情况,那么我可以继续生活。
这是我的.h文件。
#ifndef _PPM_H_
#define _PPM_H_
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
class PPM {
public:
PPM( );
int getWidth( ) const;
int getHeight( ) const;
int getMaxColorValue( ) const;
int getChannel( const int& row, const int& column, const int& channel ) const;
void setWidth( const int& width );
void setHeight( const int& height );
void setMaxColorValue( const int& max_color_value );
void setChannel( const int& row, const int& column, const int& channel, const int& value );
int getting_width;
int rhs_width;
int rhs;
int lhs;
bool operator<(const PPM& rhs);
bool operator>(const PPM& rhs);
bool operator==(const PPM& rhs);
bool operator<=(const PPM& rhs);
bool operator>=(const PPM& rhs);
bool operator!=(const PPM& rhs);
PPM operator+=(const PPM& rhs);
PPM operator-=(const PPM& rhs);
PPM operator+(const PPM& rhs) const;
PPM operator-(const PPM& rhs) const;
PPM operator*(const PPM& rhs) const;
PPM operator*=(double d);
PPM operator/=(double d);
PPM operator*(double d) const;
PPM operator/(double d) const;
void sepiaFilter( PPM& dst ) const;
private:
int mWidth;
int mHeight;
int mMAX_COLOR;
int mRow;
int mColumn;
int mChannel;
std::vector < int > Pixel;
};
std::ostream& operator << (std::ostream& output, const PPM& Pic_out);
std::istream& operator >> (std::istream &input, PPM& Pic_in);
#endif /* _PPM_H_ */
答案 0 :(得分:1)
在类中实现构造函数后,您必须在.h或cpp文件中都需要一个正文