-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathimage.lua
More file actions
35 lines (30 loc) · 1.17 KB
/
image.lua
File metadata and controls
35 lines (30 loc) · 1.17 KB
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
---@meta soluna.image
---
--- Soluna image module
---
---@class soluna.image
local image = {}
---
--- Loads an image from binary data
---
---@param data string Image file data (PNG, JPG, etc.)
---@return userdata? imagedata Image data, or nil on error
---@return integer|string width_or_error Image width, or error message on failure
---@return integer? height Image height
function image.load(data) end
---
--- Resizes an image by scale factors
---
--- The image data can be either RGBA (4 channels) or grayscale (1 channel).
--- Size is validated: for RGBA data must be width*height*4, for grayscale must be width*height.
---
---@param data userdata Image data (external string from image.load)
---@param width integer Source image width
---@param height integer Source image height
---@param scale_x number Horizontal scale factor (e.g., 0.5 for half width)
---@param scale_y? number Vertical scale factor (default: same as scale_x)
---@return userdata imagedata Resized image data
---@return integer width New width (width * scale_x, rounded)
---@return integer height New height (height * scale_y, rounded)
function image.resize(data, width, height, scale_x, scale_y) end
return image