Code Monkey home page Code Monkey logo

ktx's Introduction

ktx crates.io Documentation

KTX v1 texture storage format parsing.

Parses byte data according to https://www.khronos.org/registry/KTX/specs/1.0/ktxspec_v1.html.

// Include & use static ktx data
use ktx::{Ktx, include_ktx, KtxInfo};

let image: Ktx<_> = include_ktx!("../tests/babg-bc3.ktx");
assert_eq!(image.pixel_width(), 260);
// Read ktx data at runtime
use ktx::KtxInfo;

let decoder = ktx::Decoder::new(buf_reader)?;
assert_eq!(decoder.pixel_width(), 260);

Minimum supported rust compiler

This crate is maintained with latest stable rust.

ktx's People

Contributors

alexheretic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ktx's Issues

Cubemap

According to the specification, if array number == 0 and faces == 6 then image size contains size of a single face, this case is not processed in the Textures iterator.

To fix this, you need to multiply image size by 6, if current file is cubemap.

Error handling

Currently the function ktx::Ktx::new panics if an invalid file is provided:

fn main() {
    unsafe {
        ktx::Ktx::new(std::fs::read("/home/fctorial/.zshrc").unwrap());
    }
}

What should I do if I'm trying to load an unknown ktx file, for example, a file that I'm receiving over the network. Is there another function that returns an std::error::Error if the provided file is invalid? Does the library currently perform sanity checks on the input file (pixel_height == 0 && pixel_depth != 0 is invalid, numArrayLayers must be zero for 3d images, cubemaps must be 2d)?

Feature request: Write support

I'm considering adding support for generating ktx files in version 2.0 of the squish-rs example cli utility and this crate looks like a perfect match. Do you have any plans for write support? I can help out with the implementation if necessary but don't know if I have enough time/energy to write such a thing entirely by myself.

Looking at the current docs, I would also appreciate a bit of refactoring for an API that resembles that of the ddsfile crate more, especially wrt having enums instead of u32 for format selection (maybe with Into implementations for convenience's sake) etc.

Lacking support for KTX 2.0

Currently, the implementation assumes a KTX version of 1.1 and fails to parse with a panic (not even an error โ€” an unrecoverable panic) if the texture is a KTX 2.0 file. The latest KTX 2.0 specification is available here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.