Minecraft Map to PNG Converter
This Rust application transforms Minecraft map data from NBT format into a visual PNG image. Additionally, a WebAssembly module is available for converting images on the client side.
Features
- Convert compressed Minecraft map NBT files to PNG images.
- Direct memory-based image processing suitable for web assembly integration.
- Efficient error handling and informative error messages.
Demo Site
I provide a web interface that allows users to convert Minecraft NBT files to PNG images directly within their browser.
The website is built using HTML and Tailwind CSS for styling. It features a simple drag-and-drop interface for file upload, a convert button, and displays the resulting PNG image which can then be downloaded. The site runs entirely client-side, leveraging WebAssembly to perform image conversion.
WebAssembly Usage
To use the WebAssembly module, include the following steps in your web application:
-
Initialize the WASM Module: First, ensure that the WASM module is loaded and initialized correctly. This is done by importing the initialization function and the specific functions you need from the generated WASM package.
import init from './path_to_wasm_package/mc_map2png.js'; await ;
-
File Processing: Convert user-uploaded files by reading them into an ArrayBuffer, then passing this buffer to the WASM function:
const fileInput = document.; const file = fileInput.; const arrayBuffer = await file.; const result = await ;
-
Displaying the Image: Upon successful conversion, display the image or handle errors appropriately:
if else
-
Download Option: Provide users with the option to download the generated PNG:
const downloadButton = document.; downloadButton ;
Installation
Clone the repository to your local machine:
Build the project using Cargo:
Usage
To convert an NBT file to a PNG image, run:
Where:
<input_path>
is the path of Minecraft map NBT file. (e.g.,map_0.dat
)<output_path>
is the desired path for the output PNG file. (e.g.,map_0.png
)