bug in juce_createColourPixmapFromImage


#1

Hi Jules,

valgrind screams about this function: juce_createColourPixmapFromImage , it says “invalid memory read” , and he is right, indeed.
The correct version should replace by (HeapBlock declaration, and static_cast) , and cast colour.getData() to (char*)


#2

Yep, looks like I was having a bad day when I wrote that function! The colour assignment looks broken too, I think it should probably look like this:

[code] HeapBlock colour (width * height);
int index = 0;

    for (int y = 0; y < height; ++y)
        for (int x = 0; x < width; ++x)
            colour[index++] = image.getPixelAt (x, y).getARGB();

    XImage* ximage = XCreateImage (display, CopyFromParent, 24, ZPixmap,
                                   0, reinterpret_cast<char*> (colour.getData()),
                                   width, height, 32, 0);[/code]