Ejemplo n.º 1
0
 public function testRead()
 {
     $testPngData = file_get_contents('test/pnggrad8rgb.png');
     if ($testPngData === false) {
         throw new Exception("Failed to open test PNG file.");
     }
     $collector = new EarthIT_Collector();
     $parser = new TOGoS_PNGChunks_Parser($collector, array(TOGoS_PNGChunks_Parser::OPT_VALIDATE => true));
     $parser->data($testPngData);
     $parser->end();
     $readChunks = $collector->collection;
     $rewrittenBlob = new TOGoS_PNGChunks_PNGBlob($readChunks);
     $this->assertEquals($testPngData, (string) $rewrittenBlob);
 }
Ejemplo n.º 2
0
 public function testRead()
 {
     $fh = fopen('test/pnggrad8rgb.png', 'rb');
     if ($fh === false) {
         throw new Exception("Failed to open test PNG file.");
     }
     $collector = new EarthIT_Collector();
     $parser = new TOGoS_PNGChunks_Parser($collector, array(TOGoS_PNGChunks_Parser::OPT_VALIDATE => true));
     while (($dat = fread($fh, 100)) !== false and strlen($dat) > 0) {
         $parser->data($dat);
     }
     $parser->end();
     $x = array();
     foreach ($collector->collection as $chunk) {
         $x[] = array('typeBytes' => $chunk['typeBytes'], 'dataLength' => strlen($chunk['data']));
         //echo "{$chunk['typeBytes']} (".strlen($chunk['data'])." bytes)\n";
     }
     $this->assertEquals(array(array('typeBytes' => 'IHDR', 'dataLength' => 13), array('typeBytes' => 'IDAT', 'dataLength' => 919), array('typeBytes' => 'IEND', 'dataLength' => 0)), $x);
 }