mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
David Vogel
b1a10870c1
- Add compatibility for newest Noita beta - Modify STREAMING_CHUNK_TARGET, GRID_MAX_UPDATES_PER_FRAME and GRID_MIN_UPDATES_PER_FRAME magic numbers for a more robust capturing process - Add LimitGroup to util.go - Add webp-level command line flag to define the webp compression level - Rework progress bar to make it work in DZI export mode - Refactor image exporter functions - Use LimitGroup to make DZI export multithreaded - Add BlendMethodFast which doesn't mix tile pixels - Up Go version to 1.22 - Use Dadido3/go-libwebp for WebP encoding
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// Copyright (c) 2023-2024 David Vogel
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/cheggaaa/pb/v3"
|
|
)
|
|
|
|
func exportDZIStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar, dziTileSize, dziOverlap int, webPLevel int) error {
|
|
descriptorPath := outputPath
|
|
extension := filepath.Ext(outputPath)
|
|
outputTilesPath := strings.TrimSuffix(outputPath, extension) + "_files"
|
|
|
|
dzi := NewDZI(stitchedImage, dziTileSize, dziOverlap)
|
|
|
|
// Create base directory of all DZI files.
|
|
if err := os.MkdirAll(outputTilesPath, 0755); err != nil {
|
|
return fmt.Errorf("failed to create output directory: %w", err)
|
|
}
|
|
|
|
// Export DZI descriptor.
|
|
if err := dzi.ExportDZIDescriptor(descriptorPath); err != nil {
|
|
return fmt.Errorf("failed to export DZI descriptor: %w", err)
|
|
}
|
|
|
|
// Export DZI tiles.
|
|
if err := dzi.ExportDZITiles(outputTilesPath, bar, webPLevel); err != nil {
|
|
return fmt.Errorf("failed to export DZI tiles: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|