我正在使用Mako SDK和IJawsRenderer :: render()渲染所有具有IDOMImageBrush填充的IDOMPathNodes。当我这样做时,渲染器将为某些节点(而非全部)抛出错误2000异常。可能是什么原因?
IDOMBrushPtr pBrush;
pPath->getFill(pBrush);
if (pBrush)
{
IDOMBrush::eBrushType fillStyle = pBrush->getBrushType();
switch (fillStyle)
{
case IDOMBrush::eImage:
{
IJawsRendererPtr renderer = IJawsRenderer::create(jawsMako);
IDOMImagePtr renderedImage;
renderedImage = renderer->render(pNode, 800); // This is where the exception will eventually happen.
break;
}
default:
break;
}
}
答案 0 :(得分:0)
可能是由于传递给渲染器的路径太小而引发异常。渲染器的下限为1pt x 1pt(或1.33 x 1.33 Mako单位)。修改代码以检查节点的边界框是否足够大,例如:
const double minimumRenderSize = 96.0 / 72.0;
...
IDOMBrushPtr pBrush;
pPath->getFill(pBrush);
FRect box;
pPath->getBounds(box);
box.dX = box.dX < minimumRenderSize ? minimumRenderSize : box.dX;
box.dY = box.dY < minimumRenderSize ? minimumRenderSize : box.dY;
if (pBrush)
{
IDOMBrush::eBrushType fillStyle = pBrush->getBrushType();
switch (fillStyle)
{
case IDOMBrush::eImage:
{
IJawsRendererPtr renderer = IJawsRenderer::create(jawsMako);
IDOMImagePtr renderedImage;
renderedImage = renderer->render(pNode, 800, IDOMColorSpacesRGB::create(jawsMako), box);
break;
}
default:
break;
}
}