Documentation
¶
Overview ¶
Package iv shows images and video frames in native windows, without cgo.
The window is X11, Wayland or the DRM console on Linux, picked from the session (IV_DRIVER=x11, wayland or drm overrides it), X11 on the BSDs, Win32 on Windows and Cocoa on macOS; the x11 build tag selects X11 on Windows and macOS.
View.Display shows an image fitted to the window, View.Present shows it at the next vertical blank, and View.PresentFrame shows a YCbCr Frame (BT.601, BT.709, BT.2020, GBR or YCgCo, limited or full range), converted and scaled in hardware where the platform can; View.FramePath names the path taken.
Call New and the display methods from the main goroutine, after runtime.LockOSThread.
Index ¶
- Constants
- Variables
- type ButtonPressHandler
- type ButtonReleaseHandler
- type ClosedHandler
- type CreatedHandler
- type Cursor
- type EnterHandler
- type Frame
- type KeyPressHandler
- type KeyReleaseHandler
- type LeaveHandler
- type MotionHandler
- type Options
- type ResizeHandler
- type ScrollHandler
- type View
- func (v *View) Clear()
- func (v *View) Close() error
- func (v *View) Display(ctx context.Context, img image.Image, args ...any) error
- func (v *View) Driver() string
- func (v *View) FramePath() string
- func (v *View) Fullscreen() bool
- func (v *View) Maximize() error
- func (v *View) Present(ctx context.Context, img image.Image) error
- func (v *View) PresentFrame(ctx context.Context, f *Frame) error
- func (v *View) Raise() error
- func (v *View) ScreenSize() (int, int)
- func (v *View) SetButtonPressHandler(handler ButtonPressHandler)
- func (v *View) SetButtonReleaseHandler(handler ButtonReleaseHandler)
- func (v *View) SetClosedHandler(handler ClosedHandler)
- func (v *View) SetCreatedHandler(handler CreatedHandler)
- func (v *View) SetCursor(c Cursor) error
- func (v *View) SetEnterHandler(handler EnterHandler)
- func (v *View) SetIcon(img image.Image) error
- func (v *View) SetKeyPressHandler(handler KeyPressHandler)
- func (v *View) SetKeyReleaseHandler(handler KeyReleaseHandler)
- func (v *View) SetLeaveHandler(handler LeaveHandler)
- func (v *View) SetMotionHandler(handler MotionHandler)
- func (v *View) SetResizeHandler(handler ResizeHandler)
- func (v *View) SetScrollHandler(handler ScrollHandler)
- func (v *View) SetTitle(title string) error
- func (v *View) ToggleFullscreen() error
- func (v *View) WindowSize() (int, int)
- type Viewer
Constants ¶
const ( MatrixGBR = ycbcr.GBR MatrixYCgCo = ycbcr.YCgCo )
Matrix values for RGB-coded samples: G, B and R in the Y, Cb and Cr planes, or YCgCo.
const ( KeySpace = 65 KeyEscape = 9 KeyEnter = 36 KeyTab = 23 KeyBackspace = 22 KeyInsert = 118 KeyDelete = 119 KeyRight = 114 KeyLeft = 113 KeyDown = 116 KeyUp = 111 KeyPageUp = 112 KeyPageDown = 117 KeyHome = 110 KeyEnd = 115 KeyCapsLock = 66 KeyScrollLock = 78 KeyNumLock = 77 KeyPrintScreen = 107 KeyPause = 127 KeyF1 = 67 KeyF2 = 68 KeyF3 = 69 KeyF4 = 70 KeyF5 = 71 KeyF6 = 72 KeyF7 = 73 KeyF8 = 74 KeyF9 = 75 KeyF10 = 76 KeyF11 = 95 KeyF12 = 96 KeyLeftShift = 50 KeyLeftControl = 37 KeyLeftAlt = 64 KeyLeftSuper = 133 KeyRightShift = 62 KeyRightControl = 105 KeyRightAlt = 108 KeyRightSuper = 134 KeyLeftBracket = 34 KeyBackSlash = 51 KeyRightBracket = 35 KeyGrave = 49 KeyKp0 = 90 KeyKp1 = 87 KeyKp2 = 88 KeyKp3 = 89 KeyKp4 = 83 KeyKp5 = 84 KeyKp6 = 85 KeyKp7 = 79 KeyKp8 = 80 KeyKp9 = 81 KeyKpDecimal = 91 KeyKpDivide = 106 KeyKpMultiply = 63 KeyKpSubtract = 82 KeyKpAdd = 8 KeyKpEnter = 104 KeyApostrophe = 48 KeyComma = 59 KeyMinus = 20 KeyPeriod = 60 KeySlash = 61 Key0 = 19 Key1 = 10 Key2 = 11 Key3 = 12 Key4 = 13 Key5 = 14 Key6 = 15 Key7 = 16 Key8 = 17 Key9 = 18 KeySemicolon = 47 KeyEqual = 21 KeyA = 38 KeyB = 56 KeyC = 54 KeyD = 40 KeyE = 26 KeyF = 41 KeyG = 42 KeyH = 43 KeyI = 31 KeyJ = 44 KeyK = 45 KeyL = 46 KeyM = 58 KeyN = 57 KeyO = 32 KeyP = 33 KeyQ = 24 KeyR = 27 KeyS = 39 KeyT = 28 KeyU = 30 KeyV = 55 KeyW = 25 KeyX = 53 KeyY = 29 KeyZ = 52 ButtonLeft = 1 ButtonMiddle = 2 ButtonRight = 3 ScrollUp = 4 ScrollDown = 5 )
Variables ¶
var ( // ErrUnsupported is returned when operating system is not supported. ErrUnsupported = fmt.Errorf("unsupported os: %s", runtime.GOOS) )
Functions ¶
This section is empty.
Types ¶
type ButtonReleaseHandler ¶
type ButtonReleaseHandler func(button int)
ButtonReleaseHandler function.
type Cursor ¶ added in v0.3.0
type Cursor int
Cursor is a window cursor shape. Backends map each to the closest native cursor.
const ( // CursorDefault is the arrow cursor. CursorDefault Cursor = iota // CursorPointer is the pointing hand, used for links. CursorPointer // CursorGrab is the open hand. CursorGrab // CursorGrabbing is the closed hand, shown while dragging. CursorGrabbing // CursorText is the text I-beam. CursorText // CursorCrosshair is the crosshair. CursorCrosshair )
type Frame ¶ added in v0.6.1
type Frame struct {
*image.YCbCr
// Matrix is 601, 709, 2020, MatrixGBR or MatrixYCgCo.
Matrix int
// FullRange is set for full range samples.
FullRange bool
// Width and Height are the display size for the aspect ratio, zero for the picture size.
Width, Height int
// OSD brightens luma under its alpha, in picture coordinates.
OSD *image.Alpha
}
Frame is a YCbCr video frame and how to show it; it must stay unchanged until the next frame or image.
type Options ¶
type Options struct {
// AppID e.g. class name
AppID string
// Window width
Width int
// Window height
Height int
// DRM device index
Device int
// Text color (HEX)
TextColor string
// Window background color (HEX)
BackgroundColor string
}
Options type.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View type.
func (*View) FramePath ¶ added in v0.6.1
FramePath names how the last frame was shown, empty when the last image shown was not a frame.
func (*View) Fullscreen ¶
Fullscreen returns current fullscreen state.
func (*View) Present ¶ added in v0.6.0
Present displays image and waits until it is on screen at a vertical blank, or ctx is done.
func (*View) PresentFrame ¶ added in v0.6.1
PresentFrame presents a video frame like Present, converting and scaling it as the backend allows.
func (*View) ScreenSize ¶
ScreenSize returns screen dimensions.
func (*View) SetButtonPressHandler ¶
func (v *View) SetButtonPressHandler(handler ButtonPressHandler)
SetButtonPressHandler sets mouse button press handler.
func (*View) SetButtonReleaseHandler ¶
func (v *View) SetButtonReleaseHandler(handler ButtonReleaseHandler)
SetButtonReleaseHandler sets mouse button release handler.
func (*View) SetClosedHandler ¶
func (v *View) SetClosedHandler(handler ClosedHandler)
SetClosedHandler sets window closed handler.
func (*View) SetCreatedHandler ¶
func (v *View) SetCreatedHandler(handler CreatedHandler)
SetCreatedHandler sets window created handler.
func (*View) SetEnterHandler ¶
func (v *View) SetEnterHandler(handler EnterHandler)
SetEnterHandler sets mouse enter handler.
func (*View) SetKeyPressHandler ¶
func (v *View) SetKeyPressHandler(handler KeyPressHandler)
SetKeyPressHandler sets key press handler.
func (*View) SetKeyReleaseHandler ¶
func (v *View) SetKeyReleaseHandler(handler KeyReleaseHandler)
SetKeyReleaseHandler sets key release handler.
func (*View) SetLeaveHandler ¶
func (v *View) SetLeaveHandler(handler LeaveHandler)
SetLeaveHandler sets mouse leave handler.
func (*View) SetMotionHandler ¶
func (v *View) SetMotionHandler(handler MotionHandler)
SetMotionHandler sets mouse motion handler.
func (*View) SetResizeHandler ¶
func (v *View) SetResizeHandler(handler ResizeHandler)
SetResizeHandler sets window resize handler.
func (*View) SetScrollHandler ¶
func (v *View) SetScrollHandler(handler ScrollHandler)
SetScrollHandler sets mouse scroll handler.
func (*View) ToggleFullscreen ¶
ToggleFullscreen toggles window fullscreen.
func (*View) WindowSize ¶
WindowSize returns window dimensions.
type Viewer ¶
type Viewer interface {
Driver() string
Display(ctx context.Context, img image.Image, args ...any) error
Present(ctx context.Context, img image.Image) error
PresentFrame(ctx context.Context, f *Frame) error
FramePath() string
ToggleFullscreen() error
Fullscreen() bool
Maximize() error
Raise() error
SetTitle(string) error
SetIcon(image.Image) error
SetCursor(Cursor) error
ScreenSize() (int, int)
WindowSize() (int, int)
Close() error
Clear()
SetKeyPressHandler(handler KeyPressHandler)
SetKeyReleaseHandler(handler KeyReleaseHandler)
SetButtonPressHandler(handler ButtonPressHandler)
SetButtonReleaseHandler(handler ButtonReleaseHandler)
SetMotionHandler(handler MotionHandler)
SetScrollHandler(handler ScrollHandler)
SetEnterHandler(handler EnterHandler)
SetLeaveHandler(handler LeaveHandler)
SetResizeHandler(handler ResizeHandler)
SetCreatedHandler(handler CreatedHandler)
SetClosedHandler(handler ClosedHandler)
}
Viewer interface.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
iv
module
|
|
|
vv
module
|
|
|
internal
|
|
|
swizzle
Package swizzle converts pixel buffers between RGBA and BGRA byte order.
|
Package swizzle converts pixel buffers between RGBA and BGRA byte order. |
|
ycbcr
Package ycbcr converts YCbCr rows to RGBA or BGRA.
|
Package ycbcr converts YCbCr rows to RGBA or BGRA. |
