JUCE is drawing the wrong colour

I create a Colour of 214,218,219, and in my LookAndFeel for ::drawStandardTextButton I do a g.setColour(), then do a g.drawLine()…

Even though the colour shows as 214,218,219, it is being painted as 143,145,146, which I can prove with a screen capture.

Any idea what is causing this? :frowning:

Interestingly this does not happen if I draw a coloured line of 43,43,43, that draws as it should.

Very very odd.

I’ve had to go around this for now by doing a one line height g.fillRect…

This must be a bug for JUCE’s drawLine…

try using draw line method with a thickness of 5 and then do a screen cature and find the color of the center of the line. if it is correct then the problem most likely has to do with antialiasing. Are you passing ints or floats into drawLine?

…er, no that’s not a bug - anti-aliasing is a feature…

There’s nothing to anti alias, the line is straight across one row of pixels only. There shouldn’t be any aliasing to anti… :slight_smile:

It’s drawn with sub-pixel accuracy, so if it doesn’t exactly fill one row of pixels, the colour will depend on where it is.

If you need a solid block of pixels, don’t draw a line, fill a rectangle instead.

here’s what i was saying about aliasing:

both lines are 1px wide and you can clearly see that the aliased line looks smoother. the side effect of aliasing is that not every pixel of the drawn line is the color of the line because the alpha value of the pixel is dependant upon how far from the line the pixel is… (IIUC)

so if you are passing floats to the draw line method then the line may be partially transparent if it’s in between pixels.

Talking about antialiasing,
can i disable antialias when rendering text.
I use a bitmap font and it’s not rendered very nicely, and then i’m being diplomatic.
So any idea on how to disable this.


sorry, no chance of disabling anti-aliasing for text - it’s all done with filled paths. (Surely nobody uses really bitmap fonts in the 21st century, do they…??)

Hi Jules,
Be carefull by what you say, two experienced font designers here in my studio would strongly disagree.

Anyway, when rendering non bitmap fonts in a small corps it does look very smudgy. I attached a screenshot, any way i can get this to work better.
When the text is rendered in PS it does look much better.



Yes, it would be smudgy - it’s designed for vector-based stuff, not bitmaps. Can’t think of any way of changing it, either, unless you want to go into the Glyph code and start hacking the way it renders the paths - but I don’t recommend that!

The only thing I can think of would be to draw them at a much bigger size into an off-screen image, then downsample it onto the screen using the lowest quality interpolation. Ugh.

Or just use bigger fonts! Those silly little 5-pixel fonts are far too small to read on my laptop - it’s bad UI design to give your users eyestrain!