MagickAnnotateImage() Layer?
Posted: 2010-09-10T15:07:18-07:00
Here's a snippet of code that creates a 600x800 canvas, draws a 10x10 grid, a rounded rectangle, a curve and then some text. The rounded rectangle is drawn over top of the grid. The curve is drawn over top of the rounded rectangle and the grid. The text, however, is drawn under the grid. Is there a way to force the text to appear over top of the grid or whatever else was previously drawn?
Thanks,
Tom
Thanks,
Tom
Code: Select all
MagickWandGenesis();
m_wand = NewMagickWand();
d_wand = NewDrawingWand();
c_wand = NewPixelWand();
/* Create a new image with specified background
*/
PixelSetColor(c_wand,"white");
MagickNewImage(m_wand, 600, 800, c_wand);
DrawSetStrokeOpacity(d_wand,1);
/* Draw 10 x 10 lightblue grid on background
*/
int i;
PushDrawingWand(d_wand);
PixelSetColor(c_wand, "lightblue");
DrawSetStrokeColor(d_wand, c_wand);
DrawSetStrokeWidth(d_wand, 1);
// Draw horizontal lines
for (i = 0; i < 800; i += 10)
DrawLine(d_wand, 0, i, 600, i);
// Draw vertical lines
for (i = 0; i < 600; i += 10)
DrawLine(d_wand, i, 0, i, 800);
PopDrawingWand(d_wand);
/* Draw a rounded rectangle
*/
PushDrawingWand(d_wand);
PixelSetColor(c_wand,"yellow");
DrawSetStrokeColor(d_wand, c_wand);
DrawSetStrokeWidth(d_wand, 4);
DrawSetStrokeAntialias(d_wand, 1);
PixelSetColor(c_wand, "blue");
DrawSetStrokeOpacity(d_wand, 1);
DrawSetFillColor(d_wand, c_wand);
DrawRoundRectangle(d_wand, 30, 30, 100, 100, 10, 10);
PopDrawingWand(d_wand);
/* Draw a curve
*/
PushDrawingWand(d_wand);
{
const PointInfo points[4] =
{
{ 20, 20 }, { 100, 50 }, { 50, 100 }, { 160, 160 }
};
PixelSetColor(c_wand, "none");
DrawSetFillColor(d_wand, c_wand);
PixelSetColor(c_wand,"black");
DrawSetStrokeColor(d_wand, c_wand);
DrawSetStrokeWidth(d_wand, 4);
DrawBezier(d_wand, 4, points);
PopDrawingWand(d_wand);
}
/* Draw text
*/
PushDrawingWand(d_wand);
DrawSetFontSize(d_wand, 64);
PixelSetColor(c_wand, "red");
DrawSetFillColor(d_wand, c_wand);
PixelSetColor(c_wand,"red");
DrawSetStrokeColor(d_wand, c_wand);
MagickAnnotateImage(m_wand, d_wand, 100, 340, 45, "Apple Engineering Rocks!");
PopDrawingWand(d_wand);