Вход Регистрация
Файл: vendor/intervention/gif/src/Decoders/GifDataStreamDecoder.php
Строк: 71
<?php

declare(strict_types=1);

namespace 
InterventionGifDecoders;

use 
InterventionGifAbstractExtension;
use 
InterventionGifBlocksColorTable;
use 
InterventionGifBlocksCommentExtension;
use 
InterventionGifBlocksFrameBlock;
use 
InterventionGifBlocksHeader;
use 
InterventionGifBlocksLogicalScreenDescriptor;
use 
InterventionGifBlocksTrailer;
use 
InterventionGifExceptionsDecoderException;
use 
InterventionGifGifDataStream;

class 
GifDataStreamDecoder extends AbstractDecoder
{
    
/**
     * Decode current source to GifDataStream
     *
     * @throws DecoderException
     * @return GifDataStream
     */
    
public function decode(): GifDataStream
    
{
        
$gif = new GifDataStream();

        
$gif->setHeader(
            
Header::decode($this->handle),
        );

        
$gif->setLogicalScreenDescriptor(
            
LogicalScreenDescriptor::decode($this->handle),
        );

        if (
$gif->getLogicalScreenDescriptor()->hasGlobalColorTable()) {
            
$length $gif->getLogicalScreenDescriptor()->getGlobalColorTableByteSize();
            
$gif->setGlobalColorTable(
                
ColorTable::decode($this->handle$length)
            );
        }

        while (
$this->viewNextByte() !== Trailer::MARKER) {
            
match ($this->viewNextBytes(2)) {
                
// trailing "global" comment blocks which are not part of "FrameBlock"
                
AbstractExtension::MARKER CommentExtension::LABEL
                
=> $gif->addComment(
                    
CommentExtension::decode($this->handle)
                ),
                default => 
$gif->addFrame(
                    
FrameBlock::decode($this->handle)
                ),
            };
        }

        return 
$gif;
    }
}
Онлайн: 1
Реклама