本文整理汇总了C++中PassOwnPtr::image方法的典型用法代码示例。如果您正苦于以下问题:C++ PassOwnPtr::image方法的具体用法?C++ PassOwnPtr::image怎么用?C++ PassOwnPtr::image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PassOwnPtr
的用法示例。
在下文中一共展示了PassOwnPtr::image方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildPattern
void RenderSVGResourcePattern::buildPattern(PatternData* patternData, PassOwnPtr<ImageBuffer> tileImage) const
{
if (!tileImage->image()) {
patternData->pattern = 0;
return;
}
IntRect tileRect = tileImage->image()->rect();
if (tileRect.width() <= patternData->boundaries.width() && tileRect.height() <= patternData->boundaries.height()) {
patternData->pattern = Pattern::create(tileImage->image(), true, true);
return;
}
// Draw the first cell of the pattern manually to support overflow="visible" on all platforms.
int tileWidth = static_cast<int>(patternData->boundaries.width() + 0.5f);
int tileHeight = static_cast<int>(patternData->boundaries.height() + 0.5f);
// Don't create ImageBuffers with image size of 0
if (!tileWidth || !tileHeight) {
patternData->pattern = 0;
return;
}
OwnPtr<ImageBuffer> newTileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight));
GraphicsContext* newTileImageContext = newTileImage->context();
int numY = static_cast<int>(ceilf(tileRect.height() / tileHeight)) + 1;
int numX = static_cast<int>(ceilf(tileRect.width() / tileWidth)) + 1;
newTileImageContext->save();
newTileImageContext->translate(-patternData->boundaries.width() * numX, -patternData->boundaries.height() * numY);
for (int i = numY; i > 0; --i) {
newTileImageContext->translate(0, patternData->boundaries.height());
for (int j = numX; j > 0; --j) {
newTileImageContext->translate(patternData->boundaries.width(), 0);
newTileImageContext->drawImage(tileImage->image(), style()->colorSpace(), tileRect, tileRect);
}
newTileImageContext->translate(-patternData->boundaries.width() * numX, 0);
}
newTileImageContext->restore();
patternData->pattern = Pattern::create(newTileImage->image(), true, true);
}