QPixmap::fromImage segmentation with a non-null QImage

  • Fixed.

  • Did you try init QImage with more standard way?

    I mean try that
    @QPixmap pixmap(QPixmap::fromImage(QImage("/path/to/some/image")));@

    If it also will crash - it is problem with Qt, else problem in your code.

  • @Vass works fine. but wat do you mean "more standard way", like initialize it in the constructor or wat? If so, then i can't cause i need to get the image size from a binary file first...

  • I mean your code snippet not have information about your putPixel method, can you, please, show it?
    Just it seems like invalid format error.

  • Here is it:
    @void Sprite::putPixel(QImage &image, int x, int y, uchar red, uchar green, uchar blue, uchar alpha)
    if (image.isNull() || !image.valid(x, y))

    int n_channels = image.depth() / 8;
    Q_ASSERT_X(n_channels == 4, "Sprite::putPixel", "Invalid image channels");

    Q_ASSERT_X(x >= 0 && x < image.width(), "Sprite::putPixel", "index out of range");
    Q_ASSERT_X(y >= 0 && y < image.width(), "Sprite::putPixel", "index out of range");

    image.setPixel(x, y, qRgba(int(red), int(green), int(blue), int(alpha)));
    Or do you mean something else?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.