Jump to content

[SOLVED] Unigine::Image::setPixels crashing in 2.6.1


Recommended Posts


I'm trying to convert images from OpenSceneGraph to Unigine, the code currently looks like this :

auto osg_image = ...;
auto unigine_image = Unigine::Image::create();

img->create2D(osg_image->s(), osg_image->t(), Unigine::Image::FORMAT_RGB8);

auto data = osg_image->data();


This crashes in Unigine::Image::setPixels, in an assert at line 7285.

I've verified : data is not null.

Am I missing something here?

Thanks in advance!

Link to comment

It would be complicated to send all the dlls and the proprietary content that is used in the sample.
But here is a simple code example where the problem occurs :

auto img = Unigine::Image::create();
img->create2D(2, 2, Unigine::Image::FORMAT_RGB8, 1, 0);

unsigned char data[12] = {


I create a 2x2 image with with the RGB8 format, it crashes when trying to set the pixels values with the setPixel function.

Link to comment

Hi all,

Thanks sweetluna!

I think I understand what was going wrong with the implementation. I think that Unigine::Image protects its allocated data by default, except when it doesn't allocate anything.

Apparently setPixels only sets the value of the data pointer and doesn't do any copying.

I ended up doing a memcpy on the pointer I get from Unigine::Image::getPixels as a destination and this seems to work very well.


  • Like 1
Link to comment
  • silent changed the title to [SOLVED] Unigine::Image::setPixels crashing in 2.6.1
  • Create New...