~metalune/gofbi

ae64165c8db10cc0bac9e9759678205a62313262 — metalune 3 days ago e8d2e68 master
Readd gg.Context instance because it allows for wider support of image formats
1 files changed, 13 insertions(+), 10 deletions(-)

M main.go
M main.go => main.go +13 -10
@@ 13,11 13,6 @@ import (
)

func main() {
	// for SOME reason, if I don't use github.com/fogleman/gg somewhere, it won't recognize the images
	//TODO: FIX THIS SHIT
	dc := gg.NewContext(1, 1)
	fmt.Println(dc)

	fb := framebuffer.NewFramebuffer()
	defer fb.Release()



@@ 43,6 38,8 @@ func main() {
	flag.BoolVarP(&repeat, "repeat", "r", false, "Cycle images")
	flag.Parse()

	dc := gg.NewContext(w, h)

	for _, path := range flag.Args() {
		if _, err := os.Stat(path); err == nil {
			imgs = append(imgs, path)


@@ 78,7 75,7 @@ func main() {
	idx := 0
	max_idx := len(imgs) - 1

	draw_image(fb, imgs[idx], w, h, xoffset, yoffset)
	draw_image(fb, dc, imgs[idx], w, h, xoffset, yoffset)

	var b []byte = make([]byte, 1)
	for {


@@ 112,7 109,7 @@ func main() {

		if idx_before != idx || redraw == true {
			// only redraw when the image has changed
			go draw_image(fb, imgs[idx], w, h, xoffset, yoffset)
			go draw_image(fb, dc, imgs[idx], w, h, xoffset, yoffset)
		}

	}


@@ 121,7 118,7 @@ func main() {

}

func draw_image(fb *framebuffer.Framebuffer, path string, w int, h int, xoffset int, yoffset int) {
func draw_image(fb *framebuffer.Framebuffer, dc *gg.Context, path string, w int, h int, xoffset int, yoffset int) {
	f, err := os.Open(path)
	if err != nil {
		fmt.Println(err.Error())


@@ 135,7 132,7 @@ func draw_image(fb *framebuffer.Framebuffer, path string, w int, h int, xoffset 
	}

	// make sure that the background is black
	fb.Fill(0, 0, 0, 1)
	dc.Clear()

	i_w := img_orig.Bounds().Max.X // image width
	i_h := img_orig.Bounds().Max.Y // image height


@@ 151,5 148,11 @@ func draw_image(fb *framebuffer.Framebuffer, path string, w int, h int, xoffset 

	img := resize.Resize(uint(a_iw), uint(a_ih), img_orig, resize.NearestNeighbor)

	fb.DrawImage(xoffset+(w/2-a_iw/2), yoffset+(h/2-a_ih/2), img)
	// I know that this is slower, but it allows for wider support of image formats
	dc.DrawImage(img,
		w/2-a_iw/2,
		h/2-a_ih/2,
	)

	fb.DrawImage(xoffset, yoffset, dc.Image())
}