merge ws/tex
This commit is contained in:
commit
93a5afbe65
63 files changed
+11009
-3
No files matched your search
@@ -207,6 +207,42 @@ Read and write unless noted; see [FORMATS.md](../FORMATS.md) for depths and deta
|
||||
| TIFF | pages | yes | 1..32-bit, float |
|
||||
| BMP, TGA, QOI, ICO / CUR, PNM / PAM / PFM | ICO entries | yes | |
|
||||
| HDR | | no | float (`native` gives rgbaf32) |
|
||||
| DDS, KTX / KTX2 | faces / layers / slices | yes | GPU textures: BC1..BC7, ETC / EAC, every uncompressed layout; mips in `meta.mipmaps` |
|
||||
| OpenEXR | parts (`opts.part`) | yes | half / float / uint, NONE / RLE / ZIPS / ZIP / PIZ, tiles; writes NONE / ZIPS / ZIP |
|
||||
| PCX, SGI, Sun Raster, IFF ILBM / PBM, XPM, XBM | | yes (XBM 1-bit) | old paint / workstation formats; ILBM reads HAM and EHB |
|
||||
| ICNS, ANI | ICNS sizes / ANI steps | yes | PNG / ICO entries through the api hooks |
|
||||
|
||||
### Textures and HDR (DDS, KTX, EXR)
|
||||
|
||||
DDS and KTX files hold GPU textures: block-compressed (BC1..BC7, ETC1 / ETC2 / EAC) or plain texel layouts, with mip
|
||||
levels, cube faces and array layers. The image is the first surface; `img.frames` lists every face / layer / depth
|
||||
slice when there is more than one (`meta.layout` is `"2d"`, `"cube"`, `"array"` or `"volume"`), and with `opts.mips` the
|
||||
smaller levels of the first surface go to `meta.mipmaps`. Float and 16-bit sources keep their values with
|
||||
`opts.native` (`rgbaf32` / `rgba16`); otherwise they are clamped into `rgba8`. Writers pick the stored layout with
|
||||
`pixelFormat` (`format` is the file format): DDS writes `rgba8`, `bgra8`, `bc1`, `bc3`, `bc4`, `bc5`, `rgba16`,
|
||||
`rgba16f`, `rgba32f`; KTX2 writes the uncompressed ones.
|
||||
|
||||
```luau
|
||||
local img = assert(F.ops.image.new(64, 64))
|
||||
assert(F.ops.image.fill(img, 200, 120, 40, 255))
|
||||
local dds = assert(F.save(img, nil, { format = "dds", pixelFormat = "bc1", mips = true }))
|
||||
local tex = assert(F.load(dds, { mips = true }))
|
||||
assert(tex.meta.source.pixelFormat == "bc1" and #tex.meta.mipmaps == 6)
|
||||
local ktx = assert(F.save(img, nil, { format = "ktx", mips = true, zlib = 6 })) -- KTX2, ZLIB-supercompressed
|
||||
assert(F.detect(ktx) == "ktx")
|
||||
```
|
||||
|
||||
OpenEXR loads as linear floats with `opts.native` (`rgbaf32`); the default `rgba8` goes through the same 1 / 2.2
|
||||
display curve as Radiance HDR. `opts.part` picks a part of a multipart file, `opts.layer` reads `<layer>.R` / `.G` / ...
|
||||
|
||||
```luau
|
||||
local hdr = assert(F.ops.image.new(8, 8, "rgbaf32"))
|
||||
assert(F.ops.image.fill(hdr, 4, 2, 0.5, 1)) -- floats may exceed 1
|
||||
local exr = assert(F.save(hdr, nil, { format = "exr", compression = "zip", pixelType = "half" }))
|
||||
local linear = assert(F.load(exr, { native = true }))
|
||||
assert(linear.format == "rgbaf32" and math.abs(buffer.readf32(linear.pixels, 0) - 4) < 1e-3)
|
||||
assert(F.load(exr).format == "rgba8") -- the display conversion
|
||||
```
|
||||
|
||||
An animated image also opens as a video (`F.video.open(gifBytes)`), and saves to a video format
|
||||
(`F.convert(gifBytes, "avi")`): see [video.md](video.md).
|
||||
|
||||
+25
-3
@@ -1,8 +1,8 @@
|
||||
# Layered images (PSD, Aseprite)
|
||||
# Layered images (PSD, Aseprite, OpenRaster)
|
||||
|
||||
Photoshop documents and Aseprite sprites load as a `Layered`: a canvas size and a tree of layers, each with its own
|
||||
Photoshop documents, Aseprite sprites and OpenRaster files load as a `Layered`: a canvas size and a tree of layers, each with its own
|
||||
rgba8 [Image](image.md), position, opacity, blend mode and visibility. `F.ops.layers.flatten` composites the tree
|
||||
into one Image; `F.save` writes PSD or Aseprite, layers included. Aseprite animations also carry every frame's tree.
|
||||
into one Image; `F.save` writes PSD, Aseprite or OpenRaster, layers included. Aseprite animations also carry every frame's tree.
|
||||
|
||||
```luau
|
||||
local doc = assert(F.layered.load(psdBytes))
|
||||
@@ -230,6 +230,28 @@ assert(#back.frames == 4 and back.frames[3].layers[1].x == 3)
|
||||
|---|---|---|---|
|
||||
| PSD / PSB | 1 / 8 / 16 / 32-bit, every colour mode, layers, groups, masks, clipping | 8-bit RGB | adjustment, type and smart-object layers keep only their pixels; no layer effects |
|
||||
| Aseprite | RGBA, grayscale, indexed; frames, linked cels, tags, palette, user data | yes | tilemap layers are skipped (`meta.skipped`); slices not kept |
|
||||
| OpenRaster (ORA) | the stack tree (nested stacks = groups), offsets, opacity, visibility, svg composite-ops | yes | layers are PNGs through the api hooks; `meta.composite` = mergedimage.png |
|
||||
|
||||
### OpenRaster
|
||||
|
||||
An `.ora` file is a zip of PNG layers and a `stack.xml` tree (the format GIMP, Krita and MyPaint exchange). It loads
|
||||
like the others; nested `<stack>`s become groups (`isolation="auto"` is the `"passThrough"` blend). Saving writes every
|
||||
layer, the flattened `mergedimage.png` and a thumbnail.
|
||||
|
||||
```luau
|
||||
local doc = F.Types.Layered.new(32, 24)
|
||||
local base = assert(F.ops.image.new(32, 24))
|
||||
assert(F.ops.image.fill(base, 30, 60, 200, 255))
|
||||
local dot = assert(F.ops.image.new(8, 8))
|
||||
assert(F.ops.image.fill(dot, 255, 255, 0, 255))
|
||||
local top = F.Types.Layered.layer("dot", dot, 12, 8)
|
||||
top.blend, top.opacity = "screen", 0.5
|
||||
doc.layers = { F.Types.Layered.layer("base", base), top }
|
||||
local ora = assert(F.save(doc, nil, { format = "ora" }))
|
||||
local back = assert(F.layered.load(ora))
|
||||
assert(#back.layers == 2 and back.layers[2].blend == "screen" and back.layers[2].x == 12)
|
||||
assert(back.meta.composite.width == 32) -- mergedimage.png
|
||||
```
|
||||
|
||||
See [FORMATS.md](../FORMATS.md) for the capability matrix.
|
||||
|
||||
|
||||
Reference in new issue
Block a user