JUCE is drawing the wrong colour


#1

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:


#2

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

Very very odd.


#3

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…


#4

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?


#5

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


#6

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:


#7

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.


#8

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.


#9

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.

Cheers
Edwin


#10

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…??)


#11

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.

Cheers
Edwin


[/img][/url]


#12

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!


#13