本文整理汇总了C++中ImageResource::imageForRenderer方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageResource::imageForRenderer方法的具体用法?C++ ImageResource::imageForRenderer怎么用?C++ ImageResource::imageForRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageResource
的用法示例。
在下文中一共展示了ImageResource::imageForRenderer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeImageToDataObject
static void writeImageToDataObject(DataObject* dataObject, Element* element, const KURL& url)
{
// Shove image data into a DataObject for use as a file
ImageResource* cachedImage = getImageResource(element);
if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
return;
SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element->renderer())->data();
if (!imageBuffer || !imageBuffer->size())
return;
String imageExtension = cachedImage->image()->filenameExtension();
ASSERT(!imageExtension.isEmpty());
// Determine the filename for the file contents of the image.
String filename = cachedImage->response().suggestedFilename();
if (filename.isEmpty())
filename = url.lastPathComponent();
String fileExtension;
if (filename.isEmpty()) {
filename = element->getAttribute(HTMLNames::altAttr);
} else {
// Strip any existing extension. Assume that alt text is usually not a filename.
int extensionIndex = filename.reverseFind('.');
if (extensionIndex != -1) {
fileExtension = filename.substring(extensionIndex + 1);
filename.truncate(extensionIndex);
}
}
if (!fileExtension.isEmpty() && fileExtension != imageExtension) {
String imageMimeType = MIMETypeRegistry::getMIMETypeForExtension(imageExtension);
ASSERT(imageMimeType.startsWith("image/"));
// Use the file extension only if it has imageMimeType: it's untrustworthy otherwise.
if (imageMimeType == MIMETypeRegistry::getMIMETypeForExtension(fileExtension))
imageExtension = fileExtension;
}
imageExtension = "." + imageExtension;
validateFilename(filename, imageExtension);
dataObject->addSharedBuffer(filename + imageExtension, imageBuffer);
}
示例2: nullImage
PassRefPtr<Image> CSSCrossfadeValue::image(RenderObject* renderer, const IntSize& size)
{
if (size.isEmpty())
return 0;
ResourceFetcher* fetcher = renderer->document().fetcher();
ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), fetcher);
ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), fetcher);
if (!cachedFromImage || !cachedToImage)
return Image::nullImage();
Image* fromImage = cachedFromImage->imageForRenderer(renderer);
Image* toImage = cachedToImage->imageForRenderer(renderer);
if (!fromImage || !toImage)
return Image::nullImage();
m_generatedImage = CrossfadeGeneratedImage::create(fromImage, toImage, m_percentageValue->getFloatValue(), fixedSize(renderer), size);
return m_generatedImage.release();
}
示例3: fixedSize
IntSize CSSCrossfadeValue::fixedSize(const RenderObject* renderer)
{
float percentage = m_percentageValue->getFloatValue();
float inversePercentage = 1 - percentage;
ResourceFetcher* fetcher = renderer->document().fetcher();
ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), fetcher);
ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), fetcher);
if (!cachedFromImage || !cachedToImage)
return IntSize();
IntSize fromImageSize = cachedFromImage->imageForRenderer(renderer)->size();
IntSize toImageSize = cachedToImage->imageForRenderer(renderer)->size();
// Rounding issues can cause transitions between images of equal size to return
// a different fixed size; avoid performing the interpolation if the images are the same size.
if (fromImageSize == toImageSize)
return fromImageSize;
return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width() * percentage,
fromImageSize.height() * inversePercentage + toImageSize.height() * percentage);
}