Exemplo n.º 1
0
RepetitionCount ImageDecoder::repetitionCount() const
{
    RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyProperties(m_nativeDecoder.get(), imageSourceOptions().get()));
    if (!properties)
        return RepetitionCountOnce;
    
    CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary);
    if (gifProperties) {
        CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFLoopCount);
        
        // No property means loop once.
        if (!num)
            return RepetitionCountOnce;
        
        RepetitionCount loopCount;
        CFNumberGetValue(num, kCFNumberIntType, &loopCount);
        
        // A property with value 0 means loop forever.
        return loopCount ? loopCount : RepetitionCountInfinite;
    }
    
    CFDictionaryRef pngProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPNGDictionary);
    if (pngProperties) {
        CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(pngProperties, WebCoreCGImagePropertyAPNGLoopCount);
        if (!num)
            return RepetitionCountOnce;
        
        RepetitionCount loopCount;
        CFNumberGetValue(num, kCFNumberIntType, &loopCount);
        return loopCount ? loopCount : RepetitionCountInfinite;
    }
    
    // Turns out we're not an animated image after all, so we don't animate.
    return RepetitionCountNone;
}
Exemplo n.º 2
0
err_t MacCGDecoder::readHeader()
{
  // Do not read header more than once.
  if (_headerResult)
    return _headerResult;

  CFDictionaryRef cgDict = CGImageSourceCopyProperties(_cgImageSource, NULL);
  if (cgDict == NULL)
    return (_headerResult = ERR_IMAGEIO_INTERNAL_ERROR);

  // TODO: How to get width/height/depth and other information from the
  // cgDict?
  

  CFRelease(cgDict);
  return ERR_OK;
}
Exemplo n.º 3
0
int ImageSource::repetitionCount()
{
    int result = cAnimationLoopOnce; // No property means loop once.
    if (!initialized())
        return result;

    // A property with value 0 means loop forever.
    RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyProperties(m_decoder, imageSourceOptions()));
    if (properties) {
        CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary);
        if (gifProperties) {
            CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFLoopCount);
            if (num)
                CFNumberGetValue(num, kCFNumberIntType, &result);
        } else
            result = cAnimationNone; // Turns out we're not a GIF after all, so we don't animate.
    }
    
    return result;
}