drawImageAt automatically clipped?

Are images automatically clipped if you draw an image outside the boundaries of a clip, i.e. if I have an image 100x100 and I call repaint(25,25,50,50), can I call in paint() g.drawImageAt(image, 0, 0) instead of g.drawImage(image, 25, 25, 50, 50, 25, 25, 50, 50)? It looks like this is the case, at least in handlePaintMessage(), and indeed seems to bear out in practice, but I want to be sure before I start redundantly writing clip checking code.

  • kbj

Yup, all drawing operations via Graphics are automatically clipped.

Actually, I probably should rephrase the question as: Are there any performance penalties for assuming JUCE will automatically clip images, only blitting invalidated rectangles out of an entire image?

I am trying to make my rotary slider class more efficient. I call sin() cos() several times in a loop for both button and thumb images within setValue(), calculating the old position and the new position to create clip update areas. Doing the same thing again within paint() to draw the images only for clipped areas seemed quite a bit less efficient than to just blit the entire image within paint() and let JUCE decide which parts of that image will actually be drawn.

  • kbj

Just draw the whole thing and let the juce code clip it. No point doing the work twice by clipping it yourself as well.

Excellent! That’s what I was hoping to hear.

  • kbj