dimanche 22 novembre 2020

Static initialization of image from cimg library [duplicate]

I am working with CImgLibrary and currently trying to figure out how to initialize an static image which is a private attribute of my class MyClass. The image should be of size 1000x2000, have 3 color channels and all pixels should be black in the beginning.

#include <CImg.h>
...

class MyClass{
   public:
      // something
   private:
      static cimg_library::CImg<unsigned char> image;
}

I have tried to initialize image outside my class but nothing has worked for me so far. I have tried the following approaches:

unsigned char MyClass::image = cimg_library::CImg<unsigned char> image(1e3, 2e3, 1, 3, 0)

unsigned char MyClass::image.assign(1e3, 2e3, 1, 3, 0)

cimg_library::CImg<unsigned char> image(1e3, 2e3, 1, 3, 0)

I am fairly new to C++ and currently just desperate as I can't figure out what is wrong. Any help would be very appreciated. Thanks in advance.

Edit: For example, when I use the approach
unsigned char MyClass::image.assign(1e3, 2e3, 1, 3, 0)
I get the following error: "error: expected initializer before '.' token"

Aucun commentaire:

Enregistrer un commentaire