Skip to content

Commit

Permalink
dont decode .meta files.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-wannacott committed Nov 12, 2024
1 parent c67bb20 commit cdd4c83
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/LeeWannacott/gontage
module github.com/leewannacott/gontage

go 1.23

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync"
"time"

gontage "github.com/LeeWannacott/gontage/src"
gontage "github.com/leewannacott/gontage/src"
)

type spritesheet struct {
Expand Down
18 changes: 17 additions & 1 deletion src/gontage.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func Gontage(gargs GontageArgs) {
} else if len(sprites_folder) == 0 {
fmt.Println("Looks like folder ", gargs.Sprite_source_folder, "is empty...")
}
sprites_folder = cleanSpritesFolder(sprites_folder)

if len(sprites_folder) < gargs.Hframes {
gargs.Hframes = len(sprites_folder)
Expand Down Expand Up @@ -103,6 +104,20 @@ func Gontage(gargs GontageArgs) {
}
}

func cleanSpritesFolder(sprites_folder []fs.DirEntry) []fs.DirEntry {
var temp_sprites_folder []fs.DirEntry
for _, sprite := range sprites_folder {
switch filepath.Ext(sprite.Name()) {
case ".meta":
continue
default:
temp_sprites_folder = append(temp_sprites_folder, sprite)
}
}
sprites_folder = temp_sprites_folder
return sprites_folder
}

func decodeImages(sprites_folder []fs.DirEntry, targetFolder string, pwd string, wg *sync.WaitGroup) ([]image.Image, []string) {
defer wg.Done()
var sprites_array []image.Image
Expand All @@ -119,15 +134,16 @@ func decodeImages(sprites_folder []fs.DirEntry, targetFolder string, pwd string,
}
sprites_array = append(sprites_array, s)
sprites_names = append(sprites_names, sprite.Name())
reader.Close()
default:
s, t, err := image.Decode(reader)
if err != nil {
log.Fatalln(err, t)
}
sprites_array = append(sprites_array, s)
sprites_names = append(sprites_names, sprite.Name())
reader.Close()
}
reader.Close()
}
}
}
Expand Down

0 comments on commit cdd4c83

Please sign in to comment.