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. [Solved] BMP palettes

[Solved] BMP palettes

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • S Offline
    S Offline
    Spike89
    wrote on last edited by
    #1

    Hy.

    Is there an opportunity to make an 8-bit BMP color palette with QT?(inbuilt function or method)

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      With QImage that uses format Format_Indexed8 you can set the size of palette with "setColorCount":http://qt-project.org/doc/qt-5/qimage.html#setColorCount and then each palette element with "setColor":http://qt-project.org/doc/qt-5/qimage.html#setColor. You can then save the image in one of supported formats (including BMP) with "save":http://qt-project.org/doc/qt-5/qimage.html#save

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Spike89
        wrote on last edited by
        #3

        Thank you for your answer. But my question was not unambiguous. I want to write an 8-bit bmp header and i don't want to set all the 256 value one by one.
        I am looking for an easier and faster solution.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Qt generalizes image manipulation and doesn't provide access to specific parts of structures in specific file formats.They are just end points in the import/export.
          If you want direct access to theses bits and pieces you'll have to do it yourself or use another library. Fortunately BMP format is one of the simpler ones so it shouldn't be much trouble.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Spike89
            wrote on last edited by
            #5

            .NET has a structure: RGBTRIPLE

            @
            RGBTRIPLE ColorTable[256];

            for(int i=0;i<256;i++){
            ColorTable[i].rgbtRed=ColorTable[i].rgbtGreen=ColorTable[i].rgbtBlue=i;
            }
            @
            But how can i do this in QT?

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              quote author="Spike89" date="1402213812" and i don't want to set all the 256 value one by one. I am looking for an easier and faster solution.[/quote]
              But your example .net code does just that - sets colors one by one.

              Maybe we should rewind. What do you actually want to do with that? It looks like just a grayscale palette.
              The RGBTRIPLE seems to be a 24bit struct with 8 bits per channel. Qt uses 32bit color QColor class (8 bit for red, green, blue and alpha).
              What format do you need it in? Do you want to use it with Qt classes (like QImage, QPixmap) or with something else? Or maybe you just want a grayscale image?

              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