jcyuan
September 19, 2014, 8:25pm
1
but i got wrong result.
my target is draw an image with some specified shap masked.
my steps:
1, create a pie shape:
Path arc;
static const float FROMARC = 270.0f * RADIAN;
arc.addPieSegment(0, 0, width, height + 5.0f, FROMARC, FROMARC + m_fCurArcAngle, 0.0f);
2, update the “canvas”:
m_pathCache->clear(m_pathCache->getBounds()); //clear then now it's transparent
juce::Graphics ig(*m_pathCache);
ig.setColour(Colour(0xff000000)); /draw the pie with black to the memory image
ig.fillPath(arc);
3, final step to apply the memory ‘shape’ image to the display image:
FillType ft(*m_pathCache, AffineTransform::identity);
g.setFillType(ft);
g.drawImageAt(m_imgMaskBg, 0, 0, true); //final display
but… on my screen, the result is a black pie!
something wrong??
i need help!! guys~
jules
September 20, 2014, 1:35pm
2
Maybe you should use Graphics::reduceClipRegion to clip to your image alpha?
jcyuan
September 21, 2014, 3:57am
3
the region has same size and coords with the display image,
so i think no need to call this API?
i just made a picture to explain what i want, and my code at above as you see what:
arc -> the black pie path
m_pathCache -> the bitmpa cache to draw the pie path
m_imgMaskBg -> the original display image (and sould be the correct result to display)
thanks for your so amazing framework jules!
jules
September 21, 2014, 10:01am
4
Right, so clip to the path you want with reduceClipRegion, then just draw the entire image.
(I don't recommend using images though - this kind of thing is better done with vector graphics)
jcyuan
September 21, 2014, 2:56pm
5
this really impressed me!!
i thought that clip region only could apply square shape....
now it works very well, the memory bitmp is unnecessary.
many many thanks jules.