I need to draw a horizontal line all the way across an Image. So I’m doing this:
w = (float) img->getWidth();
g.drawLine(0.0,y,w-1,y);
The line ends one pixel before the right edge of the Image.
Looking at LowLevelGraphicsSoftwareRenderer::drawHorizontal,
I suspect that the loop that does the drawing:
while (wholeEnd > wholeStart)
{
((PixelARGB*)dest)->set (colour);
dest += dstPixelStride;
++wholeStart
}
should be changed so that the loop condition is:
I though that perhaps I was meant to do g.drawLine(0.0,y,w,y). However, if I do this, then the call to image.lockPixelDataReadWrite in drawHorizontal uses a width that is one pixel too large.
I’d be happy to use w instead of w-1 - that’s how I had it originally. It worked fine prior to JUCE 1.24.
The problem is that if I do use w, then I hit an jassert in the call to image.lockPixelDataReadWrite at the beginning of LowLevelGraphicsSoftwareRenderer::drawHorizontal.
lockPixelDataReadWrite is being passed a width of wholeEnd + 1 - wholeStart. So, for instance, if your image is 100 pixels wide and you passed in an x of 0 and a w of 100, the width passed to lockPixelDataReadWrite comes out as 101. This trips the jassert at the top of lockPixelDataReadWrite, which asserts that w <= imageWidth.
So I don’t think you can get there from here. Either the parameter to the lock call needs to change or the loop condition that draws the line needs to change. As the code stands, I really don’t see how you can draw a horizontal line that goes all the way across an image.