I want to write a function that concatenates (left to right) two PNM (P6) files that are stored pixel-by-pixel in Image
classes. I have the function set up as follows:
void LRConcatenate()
{
Image* input1 = GetInput();
Image* input2 = GetInput2();
Image* output = GetOutput();
if (input1->GetY() == input2->GetY())
{
output->ResetSize(input1->GetX()+input2->GetX(), input1->GetY());
// rest of logic goes here
}
}
So given that input1
and input2
have the same height, they should be placed in a new output
alongside each other. Are there any straightforward ways of doing this in C++? No need to write working code--I'm just trying to come up with ideas.
EDIT: My image header file, as requested:
#ifndef IPIXEL_H
#define IPIXEL_H
struct PixelStruct
{
unsigned char red;
unsigned char green;
unsigned char blue;
};
#endif
#ifndef IMAGE_H
#define IMAGE_H
class Image
{
private:
int x;
int y;
PixelStruct *data;
public:
Image(void); /* Default constructor */
Image(int width, int height, PixelStruct* data); /* Parameterized constructor */
Image(const Image& img); /* Copy constructor */
~Image(void); /* Destructor */
void ResetSize(int width, int height);
int GetX();
int GetY();
PixelStruct* GetData();
void SetData(PixelStruct *data);
};
#endif