本文整理汇总了C++中ImageResource::isLoaded方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageResource::isLoaded方法的具体用法?C++ ImageResource::isLoaded怎么用?C++ ImageResource::isLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageResource
的用法示例。
在下文中一共展示了ImageResource::isLoaded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->getImage() || !cachedImage->isLoaded())
return;
SharedBuffer* imageBuffer = cachedImage->getImage()->data();
if (!imageBuffer || !imageBuffer->size())
return;
String imageExtension = cachedImage->getImage()->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);
}