我想编写一个函数来连接(从左到右)两个在Image
类中逐像素存储的 PNM(P6)文件。我的功能设置如下:
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
}
}
因此,鉴于这一点input1
并且input2
具有相同的高度,它们应该彼此并排放置output
。在 C++ 中是否有任何直接的方法可以做到这一点?无需编写工作代码——我只是想提出一些想法。
编辑:我的图像头文件,按要求:
#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