mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Change DZI to encode tiles to WebP
This commit is contained in:
parent
8057b14d8e
commit
860b724bd0
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2023 David Vogel
|
// Copyright (c) 2023-2024 David Vogel
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
@ -35,7 +35,7 @@ func NewDZI(stitchedImage *StitchedImage, dziTileSize, dziOverlap int) DZI {
|
|||||||
dzi := DZI{
|
dzi := DZI{
|
||||||
stitchedImage: stitchedImage,
|
stitchedImage: stitchedImage,
|
||||||
|
|
||||||
fileExtension: ".png",
|
fileExtension: ".webp",
|
||||||
|
|
||||||
overlap: dziOverlap,
|
overlap: dziOverlap,
|
||||||
tileSize: dziTileSize,
|
tileSize: dziTileSize,
|
||||||
@ -82,7 +82,7 @@ func (d DZI) ExportDZIDescriptor(outputPath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dziDescriptor.Image.XMLNS = "http://schemas.microsoft.com/deepzoom/2008"
|
dziDescriptor.Image.XMLNS = "http://schemas.microsoft.com/deepzoom/2008"
|
||||||
dziDescriptor.Image.Format = "png"
|
dziDescriptor.Image.Format = "webp"
|
||||||
dziDescriptor.Image.Overlap = strconv.Itoa(d.overlap)
|
dziDescriptor.Image.Overlap = strconv.Itoa(d.overlap)
|
||||||
dziDescriptor.Image.TileSize = strconv.Itoa(d.tileSize)
|
dziDescriptor.Image.TileSize = strconv.Itoa(d.tileSize)
|
||||||
dziDescriptor.Image.Size.Width = strconv.Itoa(d.stitchedImage.bounds.Dx())
|
dziDescriptor.Image.Size.Width = strconv.Itoa(d.stitchedImage.bounds.Dx())
|
||||||
@ -121,8 +121,8 @@ func (d DZI) ExportDZITiles(outputDir string) error {
|
|||||||
rect = rect.Inset(-d.overlap)
|
rect = rect.Inset(-d.overlap)
|
||||||
img := stitchedImage.SubStitchedImage(rect)
|
img := stitchedImage.SubStitchedImage(rect)
|
||||||
filePath := filepath.Join(levelBasePath, fmt.Sprintf("%d_%d%s", iX, iY, d.fileExtension))
|
filePath := filepath.Join(levelBasePath, fmt.Sprintf("%d_%d%s", iX, iY, d.fileExtension))
|
||||||
if err := exportPNGSilent(img, filePath); err != nil {
|
if err := exportWebPSilent(img, filePath); err != nil {
|
||||||
return fmt.Errorf("failed to export PNG: %w", err)
|
return fmt.Errorf("failed to export WebP: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
scaleDivider := 2
|
scaleDivider := 2
|
||||||
|
Loading…
Reference in New Issue
Block a user