IJawsRenderer() 抛出的异常
Exception thrown by IJawsRenderer()
我正在使用 Mako SDK 和 IJawsRenderer::render() 来渲染所有带有 IDOMImageBrush 填充的 IDOMPathNode。当我这样做时,渲染器会为某些节点抛出错误 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;
}
}
可能是因为传递给渲染器的路径太小而抛出异常。渲染器的下限为 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;
}
}
我正在使用 Mako SDK 和 IJawsRenderer::render() 来渲染所有带有 IDOMImageBrush 填充的 IDOMPathNode。当我这样做时,渲染器会为某些节点抛出错误 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;
}
}
可能是因为传递给渲染器的路径太小而抛出异常。渲染器的下限为 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;
}
}