Compare commits

...
5 Commits
Author SHA1 Message Date
twocookedfaggots f0af23b36f options 2026-11-11 16:49:30 +03:00
twocookedfaggots 990506eea4 fixing 2026-11-03 11:19:11 +03:00
twocookedfaggots eab0582b93 todo 2026-11-03 10:56:10 +03:00
twocookedfaggots 73607833e5 cleaningup 2026-11-03 10:54:15 +03:00
twocookedfaggots 84f0b9e4c2 todo 2026-11-03 10:53:30 +03:00
5 changed files with 59 additions and 4 deletions

No files matched your search

+1
View File
@@ -2,6 +2,7 @@ child_porn
imageutils.test imageutils.test
cpu.out cpu.out
profile.out profile.out
bin/
*.png *.png
*.gif *.gif
*.jpg *.jpg
+5 -2
View File
@@ -1,12 +1,15 @@
# imageutils # imageutils
## that is exactly image utilities, what i made for myself ## 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)|| ||(with a dummy as fuck image rescaling)||
utilities work in theory, but doing everything very slow. 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. i really love Go's image.Image interface type, but its really hard to do something with it well.
TODO: TODO:
- create main binary that give access to all implemented things in cmd/ - restructure directories and files
- 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
+21
View File
@@ -0,0 +1,21 @@
//go:build todo
package ttyimageviewer
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)
}
}
+1 -1
View File
@@ -65,6 +65,6 @@ func (d Dithering) ColorModel() color.Model { return color.GrayModel }
func (d Dithering) Bounds() image.Rectangle { return d.Image.Bounds() } func (d Dithering) Bounds() image.Rectangle { return d.Image.Bounds() }
func (d Dithering) At(x, y int) color.Color { func (d Dithering) At(x, y int) color.Color {
c := color.GrayModel.Convert(d.Image.At(x, y)) c := color.GrayModel.Convert(d.Image.At(x, y))
return uniformGrid{grid{c.(color.Gray), d.Options.Factor}}. return uniformGrid{grid{c.(color.Gray), d.Options}}.
At(x, y) At(x, y)
} }
+31 -1
View File
@@ -5,9 +5,12 @@ import (
"fmt" "fmt"
"image" "image"
"image/color" "image/color"
"io"
"os" "os"
"path/filepath"
) )
/* old version that worked some time for some reason
func Resolution() (w int, h int) { func Resolution() (w int, h int) {
resFile, err := os.Open("/sys/class/graphics/fb0/virtual_size") resFile, err := os.Open("/sys/class/graphics/fb0/virtual_size")
if err != nil { if err != nil {
@@ -22,6 +25,33 @@ func Resolution() (w int, h int) {
fmt.Sscanf(s, "%d,%d", &w, &h) fmt.Sscanf(s, "%d,%d", &w, &h)
return 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 devfb *os.File
var width, height = Resolution() var width, height = Resolution()
@@ -53,7 +83,7 @@ func Draw(img image.Image) error {
if err != nil { if err != nil {
return err return err
} }
_, err := devfb.Seek(0,0) _, err = devfb.Seek(0, 0)
if err != nil { if err != nil {
return err return err
} }