-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathVipsSourceCustom.php
52 lines (46 loc) · 1.5 KB
/
VipsSourceCustom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Jcupitt\Vips;
use Closure;
class VipsSourceCustom extends VipsSource
{
/**
* A pointer to the underlying VipsSourceCustom. This is the same as the
* GObject, just cast to VipsSourceCustom to help FFI.
*
* @internal
*/
public \FFI\CData $pointer;
public function __construct()
{
$this->pointer = FFI::vips()->vips_source_custom_new();
parent::__construct($this->pointer);
}
/**
* Attach a read handler.
* The interface is similar to fread. The handler is given a number
* of bytes to fetch, and should return a bytes-like object containing up
* to that number of bytes. If there is no more data available, it should
* return null.
*/
public function onRead(Closure $callback): void
{
$this->signalConnect('read', $callback);
}
/**
* Attach a seek handler.
* The interface is the same as fseek, so the handler is passed
* parameters for $offset and $whence with the same meanings.
* However, the handler MUST return the new seek position. A simple way
* to do this is to call ftell() and return that result.
* Seek handlers are optional. If you do not set one, your source will be
* treated as unseekable and libvips will do extra caching.
* $whence in particular:
* 0 => start
* 1 => current position
* 2 => end
*/
public function onSeek(Closure $callback): void
{
$this->signalConnect('seek', $callback);
}
}