imgA: jpeg opts.native (grey files -> gray8); Dct local type annotations
This commit is contained in:
1 parent
c394e8309f
commit
1824489291
3 files changed
+16
-1
No files matched your search
@@ -34,6 +34,7 @@ local Jpeg = {
|
||||
export type DecodeOptions = {
|
||||
scale: number?, -- 1 (default), 2, 4 or 8: decode at ceil(size / scale) (8 reads the DC coefficients only)
|
||||
orient: boolean?, -- apply the EXIF orientation (default false: reported in meta.orientation only)
|
||||
native: boolean?, -- grey files decode to gray8 (default false: rgba8)
|
||||
maxPixels: number?, -- refuse larger images (default 2^26)
|
||||
}
|
||||
export type EncodeOptions = {
|
||||
@@ -160,6 +161,13 @@ function Jpeg.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Image?, Err.
|
||||
end
|
||||
local img = Types.Image.new(1, 1)
|
||||
img.width, img.height, img.pixels = w, h, px
|
||||
if opts and opts.native and space == "gray" then
|
||||
local g = buffer.create(w * h)
|
||||
for i = 0, w * h - 1 do
|
||||
buffer.writeu8(g, i, buffer.readu8(px, i * 4))
|
||||
end
|
||||
img.pixels, img.format = g, "gray8"
|
||||
end
|
||||
local f = st.frame
|
||||
local sampling = {}
|
||||
for _, c in f.comps do
|
||||
|
||||
Reference in new issue
Block a user