todo
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
# imageutils
|
||||
## that is exactly image utilities, what i made for myself
|
||||
|
||||
all the 2d graphics related stuff now moves there
|
||||
all the 2d graphics related stuff that i've made now moves there
|
||||
|
||||
||(with a dummy as fuck image rescaling)||
|
||||
utilities work in theory, but doing everything very slow.
|
||||
i really love Go's image.Image interface type, but its really hard to do something with it well.
|
||||
|
||||
TODO:
|
||||
- create main binary that give access to all implemented things in cmd/
|
||||
- create main binary/module that give access to all implemented things in cmd/
|
||||
- create access to framebuffer without /dev/fb (imageutils/util/fb doesn't work for now)
|
||||
- figure out image rotating mechanism
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//go:build todo (doesn't work)
|
||||
package main
|
||||
|
||||
import (
|
||||
"image"
|
||||
"os"
|
||||
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/util/fb"
|
||||
)
|
||||
|
||||
func main() {
|
||||
img, format, err := image.Decode(os.Stdin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
println("registered format:", format)
|
||||
err = fb.Draw(img)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
+31
-1
@@ -5,9 +5,12 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
/* old version that worked some time for some reason
|
||||
func Resolution() (w int, h int) {
|
||||
resFile, err := os.Open("/sys/class/graphics/fb0/virtual_size")
|
||||
if err != nil {
|
||||
@@ -22,6 +25,33 @@ func Resolution() (w int, h int) {
|
||||
fmt.Sscanf(s, "%d,%d", &w, &h)
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func Resolution() (w int, h int) {
|
||||
matches, err := filepath.Glob("sys/class/drm/*/modes")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, match := range matches {
|
||||
f, err := os.Open(match)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r := bufio.NewReader(f)
|
||||
s, err := r.ReadString('\n')
|
||||
if err != nil {
|
||||
switch err {
|
||||
case io.EOF:
|
||||
continue
|
||||
default:
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
fmt.Sscanf(s, "%dx%d", &w, &h)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var devfb *os.File
|
||||
var width, height = Resolution()
|
||||
@@ -53,7 +83,7 @@ func Draw(img image.Image) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := devfb.Seek(0,0)
|
||||
_, err = devfb.Seek(0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func main() {
|
||||
matches, err := filepath.Glob("/sys/class/drm/*/modes")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(matches)
|
||||
for _, match := range matches {
|
||||
f, err := os.Open(match)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r := bufio.NewReader(f)
|
||||
s, err := r.ReadString('\n')
|
||||
if err != nil {
|
||||
switch err {
|
||||
case io.EOF:
|
||||
continue
|
||||
default:
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
fmt.Print(s)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user