Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPixmap::fromImage segmentation with a non-null QImage
Forum Updated to NodeBB v4.3 + New Features

QPixmap::fromImage segmentation with a non-null QImage

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QLover
    wrote on last edited by
    #1

    Fixed.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      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.

      --
      Vasiliy

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QLover
        wrote on last edited by
        #3

        @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...

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on last edited by
          #4

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

          --
          Vasiliy

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QLover
            wrote on last edited by
            #5

            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))
            return;

            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?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved