Optimized

This commit is contained in:
bradley.richins
2020-10-20 16:23:57 -06:00
parent f291891139
commit 4f1002ee2d
2 changed files with 21 additions and 21 deletions

View File

@@ -24,6 +24,8 @@ func CreateBanner(portalhex string, savename string, vopt int) {
var err error
var GlyphHex [12]int64
var glyphImg [12]string
var vert int
var horz int
// Setup temp dir
tempdir, err := ioutil.TempDir("", "nmslib-")
@@ -71,25 +73,23 @@ func CreateBanner(portalhex string, savename string, vopt int) {
{ImageFilePath: tempdir + "/" + glyphImg[8]}, {ImageFilePath: tempdir + "/" + glyphImg[9]},
{ImageFilePath: tempdir + "/" + glyphImg[10]}, {ImageFilePath: tempdir + "/" + glyphImg[11]},
}
if vopt == 1 {
// Merge images horizontally
rgba, err := gim.New(grids, 1, 12).Merge()
if err != nil {
panic(err)
}
// save the output to png
fmt.Printf("Saving %s to %s in vertical format\n", portalhex, savename)
file, err := os.Create(savename)
err = png.Encode(file, rgba)
} else {
// Merge images vertically
rgba, err := gim.New(grids, 12, 1).Merge()
if err != nil {
panic(err)
}
// save the output to png
fmt.Printf("Saving %s to %s\n", portalhex, savename)
file, err := os.Create(savename)
err = png.Encode(file, rgba)
if vopt == 1 { // set vertical rendering
vert, horz = 1, 12
} else { // set horizontal rendering (default)
vert, horz = 12, 1
}
// create new image from grids
rgba, err := gim.New(grids, vert, horz).Merge()
if err != nil {
panic(err)
}
// save the output to png
fmt.Printf("Saving %s to %s\n", portalhex, savename)
file, err := os.Create(savename)
err = png.Encode(file, rgba)
if err != nil {
fmt.Println(err)
}
}

View File

@@ -77,7 +77,6 @@ func Eng2Korvax(enwrd string) string {
if err != nil {
fmt.Println(err)
}
defer csvFile.Close()
csvlines, err := csv.NewReader(csvFile).ReadAll()
if err != nil {
fmt.Println(err)
@@ -93,5 +92,6 @@ func Eng2Korvax(enwrd string) string {
return klang.korvax
}
}
csvFile.Close()
return "*\\Kzzzzzzt\\*" // word not found default
}