mirror of
https://github.com/gen2brain/cbconvert
synced 2026-06-30 09:11:54 +02:00
Handle Lossless
This commit is contained in:
@@ -148,6 +148,8 @@ func settingsApply(group string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userLossless = iup.GetHandle("Lossless").GetAttribute("VALUE") == "ON"
|
||||||
|
|
||||||
syncLabels()
|
syncLabels()
|
||||||
setActive()
|
setActive()
|
||||||
previewPost()
|
previewPost()
|
||||||
|
|||||||
@@ -1,10 +1,40 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gen2brain/cbconvert/cmd/cbconvert-gui/i18n"
|
"github.com/gen2brain/cbconvert/cmd/cbconvert-gui/i18n"
|
||||||
"github.com/gen2brain/iup-go/iup"
|
"github.com/gen2brain/iup-go/iup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// jxlLosslessBuild reports whether wasm2go and nodynamic leave zune-jpegxl (lossless-only) as the only jxl encoder.
|
||||||
|
var jxlLosslessBuild = func() bool {
|
||||||
|
info, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var wasm2go, nodynamic bool
|
||||||
|
for _, kv := range info.Settings {
|
||||||
|
if kv.Key != "-tags" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, t := range strings.Split(kv.Value, ",") {
|
||||||
|
switch t {
|
||||||
|
case "wasm2go":
|
||||||
|
wasm2go = true
|
||||||
|
case "nodynamic":
|
||||||
|
nodynamic = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wasm2go && nodynamic
|
||||||
|
}()
|
||||||
|
|
||||||
|
// userLossless is the user's Lossless preference, tracked separately because a jxl
|
||||||
|
// wasm2go build force-sets the widget on.
|
||||||
|
var userLossless bool
|
||||||
|
|
||||||
func setActive() {
|
func setActive() {
|
||||||
if busy {
|
if busy {
|
||||||
return
|
return
|
||||||
@@ -68,7 +98,15 @@ func setActive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canLossless := opts.Format == "webp" || opts.Format == "avif" || opts.Format == "jxl"
|
canLossless := opts.Format == "webp" || opts.Format == "avif" || opts.Format == "jxl"
|
||||||
losslessOn := canLossless && opts.Lossless
|
jxlLossless := jxlLosslessBuild && opts.Format == "jxl"
|
||||||
|
|
||||||
|
// jxl wasm2go forces lossless on; otherwise show the user's preference so it doesn't stay stuck on.
|
||||||
|
losslessVal := "OFF"
|
||||||
|
if jxlLossless || userLossless {
|
||||||
|
losslessVal = "ON"
|
||||||
|
}
|
||||||
|
iup.GetHandle("Lossless").SetAttribute("VALUE", losslessVal)
|
||||||
|
losslessOn := jxlLossless || (canLossless && userLossless)
|
||||||
|
|
||||||
if (opts.Format == "jpeg" || canLossless) && !opts.NoConvert && !losslessOn {
|
if (opts.Format == "jpeg" || canLossless) && !opts.NoConvert && !losslessOn {
|
||||||
iup.GetHandle("VboxQuality").SetAttribute("ACTIVE", "YES")
|
iup.GetHandle("VboxQuality").SetAttribute("ACTIVE", "YES")
|
||||||
@@ -84,6 +122,11 @@ func setActive() {
|
|||||||
iup.GetHandle("Lossless").SetAttribute("ACTIVE", "NO")
|
iup.GetHandle("Lossless").SetAttribute("ACTIVE", "NO")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if jxlLossless {
|
||||||
|
iup.GetHandle("Lossless").SetAttribute("ACTIVE", "NO")
|
||||||
|
iup.GetHandle("VboxEffort").SetAttribute("ACTIVE", "NO")
|
||||||
|
}
|
||||||
|
|
||||||
if opts.Width != 0 && opts.Height != 0 && !opts.NoConvert {
|
if opts.Width != 0 && opts.Height != 0 && !opts.NoConvert {
|
||||||
iup.GetHandle("Fit").SetAttribute("ACTIVE", "YES")
|
iup.GetHandle("Fit").SetAttribute("ACTIVE", "YES")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func list() iup.Ihandle {
|
|||||||
"TITLE1": i18n.Lng(i18n.ColTitle),
|
"TITLE1": i18n.Lng(i18n.ColTitle),
|
||||||
"TITLE2": i18n.Lng(i18n.ColType),
|
"TITLE2": i18n.Lng(i18n.ColType),
|
||||||
"TITLE3": i18n.Lng(i18n.ColSize),
|
"TITLE3": i18n.Lng(i18n.ColSize),
|
||||||
"WIDTH1": "300",
|
"WIDTH1": "250",
|
||||||
"WIDTH2": "50",
|
"WIDTH2": "50",
|
||||||
"WIDTH3": "100",
|
"WIDTH3": "100",
|
||||||
"ALIGNMENT2": "ACENTER",
|
"ALIGNMENT2": "ACENTER",
|
||||||
@@ -568,6 +568,7 @@ func tabImage() iup.Ihandle {
|
|||||||
iup.Toggle(i18n.Lng(i18n.TglLossless)).SetHandle("Lossless").
|
iup.Toggle(i18n.Lng(i18n.TglLossless)).SetHandle("Lossless").
|
||||||
SetAttribute("TIP", i18n.Lng(i18n.TipLossless)).
|
SetAttribute("TIP", i18n.Lng(i18n.TipLossless)).
|
||||||
SetCallback("VALUECHANGED_CB", iup.ValueChangedFunc(func(ih iup.Ihandle) int {
|
SetCallback("VALUECHANGED_CB", iup.ValueChangedFunc(func(ih iup.Ihandle) int {
|
||||||
|
userLossless = ih.GetAttribute("VALUE") == "ON"
|
||||||
setActive()
|
setActive()
|
||||||
previewPost()
|
previewPost()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user