Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
lbm2png converts LBM to PNG
package main
import (
"flag"
"image/png"
"log"
"os"
"github.com/textmodes/parser/image/ilbm"
)
func main() {
log := log.New(os.Stderr, "", 0)
flag.Parse()
if flag.NArg() != 2 {
log.Println("Usage: lbm2png input.lbm output.png")
return
}
input, output := flag.Arg(0), flag.Arg(1)
f, err := os.Open(input)
if err != nil {
log.Fatal(err)
}
m, err := ilbm.Decode(f)
if err != nil {
log.Fatal(err)
}
w, err := os.Create(output)
if err != nil {
log.Fatal(err)
}
defer w.Close()
if err := png.Encode(w, m); err != nil {
log.Fatal(err)
}
}
@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Oct 15, 2019

@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Oct 15, 2019

Using my https://github.com/peterhellberg/gfx package:

package main

import (
	"flag"

	"github.com/peterhellberg/gfx"
	"github.com/textmodes/parser/image/ilbm"
)

func main() {
	flag.Parse()

	if flag.NArg() != 2 {
		gfx.Log("Usage: lbm2png input.lbm output.png")
		return
	}

	input, output := flag.Arg(0), flag.Arg(1)

	f, err := gfx.OpenFile(input)
	if err != nil {
		gfx.Fatal(err)
	}
	defer f.Close()

	m, err := ilbm.Decode(f)
	if err != nil {
		gfx.Fatal(err)
	}

	gfx.SavePNG(output, m)
}
@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Oct 15, 2019

@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Oct 16, 2019

Editor for binary files: https://github.com/itchyny/bed (for example .JET)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.