Image
クラスにピクセル単位で格納されている 2 つの 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
互いに並べて new に配置する必要があります。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