Important: Please read the Qt Code of Conduct -

Converting display to single color output

  • I'm writing an application that needs to output all items using only a single color, green. The display device can only show green and doesn't do the color conversion itself. I'm using full color SVG images as well as custom drawing to accomplish the requirements for the display, but need a way to render the SVG images using only a single color. Being new to Qt, I'm not sure what I need in order to accomplish this goal, but I'm hoping you all can help.


  • Moderators

    Is it 2-bit green, or multiple shades of green?

  • Just a single shade of green. It's a transparent display, so it's either green or nothing (black).

  • Moderators

    You probably want to look at "QBitmap":

    Edit: There's also a nice SVG rendering example "here": Also, a key phrase from the QBitmap docs is: "If a pixmap with a depth greater than 1 is assigned to a bitmap, the bitmap will be dithered automatically."

    Just a few thoughts...

  • I saw that, but didn't see how I could tell it that the colors I wanted to use was green/black instead of black/white. Also, I have two prototype systems, one using QPixmap to render the images and the other using QGraphicsSvgItem. While QBitmap could be used as a substitute in the first case, I don't know how I could use it for the second. What could I do in that case?

    Is there a way i can adjust some sort of global palette?

  • Moderators

    Hmm... I'm not sure I fully understand what you're wanting to do then. It's probably because I'm still thinking in terms of my early days when mono displays weren't that uncommon and regardless of whether they were green or white or amber, they were still moreless representing a black & white image (which just happened to be displayed as black and green or black and amber or whatever.)

    Are you trying to pull just the greenish elements from the SVG and display them? Or trying to represent the full color image as dithered shades of green? How do you intend to handle, say, something that's red or blue in your source image?

  • What I want to do is take whatever color is there and have it be green. The display device I'm using only displays the green channel of color, so if any other color is used, it's essentially hidden by this device.

  • Moderators

    Perhaps you should just map it to a greyscale image which creates the same values in the red, green, and blue channels. If you then toss out the red and blue channels, the green should be sane, I would think.

    Or, is there any chance of pre-adjusting the SVG files so they're just green?

  • I could adjust the SVG files that come prepackaged (9,000 files), but at some point new images will be issued to the system programatically and the program will need to be able to handle converting them to all green. Better in the long run to just do that conversion now.

  • Moderators

    Aside from what I've mentioned, I really don't have a lot of other insight without a better idea of what the source files look like and how they're envisioned of appearing in the final display, etc.

    I hope you have some better ideas now after this exchange, or that anyone else might have some good insight.

Log in to reply