本文整理汇总了C++中HTMLImageElement::setImageResource方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLImageElement::setImageResource方法的具体用法?C++ HTMLImageElement::setImageResource怎么用?C++ HTMLImageElement::setImageResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLImageElement
的用法示例。
在下文中一共展示了HTMLImageElement::setImageResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IntRect
TEST_F(ImageBitmapTest, ImageResourceConsistency)
{
const ImageBitmapOptions defaultOptions;
HTMLImageElement* imageElement = HTMLImageElement::create(*Document::create());
ImageResource* image = ImageResource::create(StaticBitmapImage::create(m_image).get());
imageElement->setImageResource(image);
ImageBitmap* imageBitmapNoCrop = ImageBitmap::create(imageElement,
IntRect(0, 0, m_image->width(), m_image->height()),
&(imageElement->document()), defaultOptions);
ImageBitmap* imageBitmapInteriorCrop = ImageBitmap::create(imageElement,
IntRect(m_image->width() / 2, m_image->height() / 2, m_image->width() / 2, m_image->height() / 2),
&(imageElement->document()), defaultOptions);
ImageBitmap* imageBitmapExteriorCrop = ImageBitmap::create(imageElement,
IntRect(-m_image->width() / 2, -m_image->height() / 2, m_image->width(), m_image->height()),
&(imageElement->document()), defaultOptions);
ImageBitmap* imageBitmapOutsideCrop = ImageBitmap::create(imageElement,
IntRect(-m_image->width(), -m_image->height(), m_image->width(), m_image->height()),
&(imageElement->document()), defaultOptions);
ASSERT_EQ(imageBitmapNoCrop->bitmapImage()->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
ASSERT_NE(imageBitmapInteriorCrop->bitmapImage()->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
ASSERT_NE(imageBitmapExteriorCrop->bitmapImage()->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
StaticBitmapImage* emptyImage = imageBitmapOutsideCrop->bitmapImage();
ASSERT_NE(emptyImage->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
}