Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Raster\Encoder; |
| 6 | |
| 7 | use Phpdftk\Raster\RasterSurface; |
| 8 | |
| 9 | /** |
| 10 | * Encode a {@see RasterSurface} to a binary format ready for |
| 11 | * embedding in a PDF or saving to disk. Implementations: |
| 12 | * |
| 13 | * - `PngEncoder` PNG bytes (4C.5) |
| 14 | * - `JpegEncoder` JPEG bytes for opaque surfaces (future) |
| 15 | * - `RawEncoder` flat RGBA bytes for tests / debugging |
| 16 | * |
| 17 | * The PDF wrapping (turning the encoded bytes into an Image XObject |
| 18 | * with the right `/Filter` + `/ColorSpace` + `/BitsPerComponent` |
| 19 | * entries) is the translator's job, not the encoder's. |
| 20 | */ |
| 21 | interface EncoderInterface |
| 22 | { |
| 23 | /** |
| 24 | * Return the encoded bytes. Implementations choose how to |
| 25 | * handle alpha — PNG carries it directly; JPEG would need to |
| 26 | * composite over a background. |
| 27 | */ |
| 28 | public function encode(RasterSurface $surface): string; |
| 29 | } |