2019-10-21 00:07:39 +00:00
|
|
|
// Copyright (c) 2019 David Vogel
|
|
|
|
//
|
|
|
|
// This software is released under the MIT License.
|
|
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-23 01:28:37 +00:00
|
|
|
"image"
|
|
|
|
"image/png"
|
2019-10-21 00:07:39 +00:00
|
|
|
"log"
|
2019-10-23 01:28:37 +00:00
|
|
|
"os"
|
2019-10-21 00:07:39 +00:00
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
var inputPath = filepath.Join(".", "..", "..", "output")
|
|
|
|
|
|
|
|
func main() {
|
2019-10-23 22:28:22 +00:00
|
|
|
log.Printf("Starting to read tile information at \"%v\"", inputPath)
|
2019-10-21 00:07:39 +00:00
|
|
|
tiles, err := loadImages(inputPath)
|
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
2019-10-23 22:28:22 +00:00
|
|
|
log.Printf("Got %v tiles", len(tiles))
|
2019-10-21 00:07:39 +00:00
|
|
|
|
2019-10-24 01:05:42 +00:00
|
|
|
/*profFile, err := os.Create("cpu.prof")
|
2019-10-23 01:28:37 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Panicf("could not create CPU profile: %v", err)
|
|
|
|
}
|
2019-10-24 01:05:42 +00:00
|
|
|
defer profFile.Close()
|
|
|
|
if err := pprof.StartCPUProfile(profFile); err != nil {
|
2019-10-23 01:28:37 +00:00
|
|
|
log.Panicf("could not start CPU profile: %v", err)
|
|
|
|
}
|
|
|
|
defer pprof.StopCPUProfile()*/
|
|
|
|
|
2019-10-24 01:05:42 +00:00
|
|
|
// TODO: Flags / Program arguments
|
|
|
|
|
|
|
|
outputRect := image.Rect(-35000, -35000, 35000, 35000)
|
2019-10-23 01:28:37 +00:00
|
|
|
|
2019-10-23 22:28:22 +00:00
|
|
|
log.Printf("Creating output image with a size of %v", outputRect.Size())
|
|
|
|
outputImage := image.NewRGBA(outputRect)
|
|
|
|
|
|
|
|
log.Printf("Stitching %v tiles into an image at %v", len(tiles), outputImage.Bounds())
|
2019-10-23 01:28:37 +00:00
|
|
|
tp := make(tilePairs)
|
2019-10-24 01:05:42 +00:00
|
|
|
if err := tp.StitchGrid(tiles, outputImage, 1024); err != nil {
|
2019-10-23 01:28:37 +00:00
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
2019-10-23 22:28:22 +00:00
|
|
|
log.Printf("Creating output file \"%v\"", "output.png")
|
2019-10-23 01:28:37 +00:00
|
|
|
f, err := os.Create("output.png")
|
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := png.Encode(f, outputImage); err != nil {
|
|
|
|
f.Close()
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := f.Close(); err != nil {
|
|
|
|
log.Panic(err)
|
2019-10-21 00:07:39 +00:00
|
|
|
}
|
2019-10-23 22:28:22 +00:00
|
|
|
log.Printf("Created output file \"%v\"", "output.png")
|
|
|
|
|
2019-10-21 00:07:39 +00:00
|
|
|
}
|