diff options
| author | Valentin Popov <valentin@popov.link> | 2025-06-15 01:42:55 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-15 01:42:55 +0300 |
| commit | 2273fd4263b91a877b043dacf4b9311c98d3bcbb (patch) | |
| tree | e2502636adc081c2a71179402774fa90d5be8a9d /texture-decoder/src/main.rs | |
| parent | d4f104cf5ebca5acf4379e5108c635e008c0c82f (diff) | |
| parent | d274602104892e181205725c6b9c9082a9669942 (diff) | |
| download | fparkan-2273fd4263b91a877b043dacf4b9311c98d3bcbb.tar.xz fparkan-2273fd4263b91a877b043dacf4b9311c98d3bcbb.zip | |
Merge pull request #7 from valentineus/nres
Обновление структуры проекта
Diffstat (limited to 'texture-decoder/src/main.rs')
| -rw-r--r-- | texture-decoder/src/main.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/texture-decoder/src/main.rs b/texture-decoder/src/main.rs deleted file mode 100644 index 26c7edd..0000000 --- a/texture-decoder/src/main.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::io::Read; - -use byteorder::ReadBytesExt; -use image::Rgba; - -fn decode_texture(file_path: &str, output_path: &str) -> Result<(), std::io::Error> { - // Читаем файл - let mut file = std::fs::File::open(file_path)?; - let mut buffer: Vec<u8> = Vec::new(); - file.read_to_end(&mut buffer)?; - - // Декодируем метаданные - let mut cursor = std::io::Cursor::new(&buffer[4..]); - let img_width = cursor.read_u32::<byteorder::LittleEndian>()?; - let img_height = cursor.read_u32::<byteorder::LittleEndian>()?; - - // Пропустить оставшиеся байты метаданных - cursor.set_position(20); - - // Извлекаем данные изображения - let image_data = buffer[cursor.position() as usize..].to_vec(); - let img = - image::ImageBuffer::<Rgba<u8>, _>::from_raw(img_width, img_height, image_data.to_vec()) - .expect("Failed to decode image"); - - // Сохраняем изображение - img.save(output_path).unwrap(); - - Ok(()) -} - -fn main() { - let args: Vec<String> = std::env::args().collect(); - - let input = &args[1]; - let output = &args[2]; - - if let Err(err) = decode_texture(input, output) { - eprintln!("Error: {}", err) - } -} |
