Git Product home page Git Product logo

Comments (3)

RandomInsano avatar RandomInsano commented on August 27, 2024

Results of pngcheck on "master" branch:

     Running `target/release/examples/pngcheck /Users/me/Downloads/font.png`
OK: /Users/me/Downloads/font.png (256x256, 1-bit palette, non-interlaced, 94.9%)
$ cargo run --release --example pngcheck -- -v ~/Downloads/font.png
    Finished release [optimized] target(s) in 0.07s
     Running `target/release/examples/pngcheck -v /Users/me/Downloads/font.png`
File: /Users/me/Downloads/font.png (10240) bytes
  chunk ChunkType { type: IHDR, critical: true, private: false, reserved: false, safecopy: false } at offset 0x0000c, length 13
    256 x 256 image, 1-bit palette, non-interlaced
  chunk ChunkType { type: gAMA, critical: false, private: false, reserved: false, safecopy: false } at offset 0x00025, length 4
  chunk ChunkType { type: sRGB, critical: false, private: false, reserved: false, safecopy: false } at offset 0x00035, length 1
  chunk ChunkType { type: pHYs, critical: false, private: false, reserved: false, safecopy: true } at offset 0x00042, length 9
  chunk ChunkType { type: PLTE, critical: true, private: false, reserved: false, safecopy: false } at offset 0x00057, length 6
  chunk ChunkType { type: IDAT, critical: true, private: false, reserved: false, safecopy: false } at offset 0x00069, length 1256
  chunk ChunkType { type: IEND, critical: true, private: false, reserved: false, safecopy: false } at offset 0x0055d, length 0
No errors detected in /Users/me/Downloads/font.png (7 chunks, 94.9% compression)

from image-png.

RandomInsano avatar RandomInsano commented on August 27, 2024

Hmm. Using the show example, it does load properly.

My code to load the image looks like this:

        let decoder = Decoder::new(file);
        let mut reader = match decoder.read_info() {
            Ok(x) => x,
            Err(x) => match x {
                DecodingError::IoError(x) => return Err(x),
                _ => panic!("Unable to decode image header")
            }
        };

        // Load the image
        let mut pixels = vec![0; reader.output_buffer_size()];
        match reader.next_frame(&mut pixels) {
            Ok(_) => {},
            Err(x) => match x {
                DecodingError::IoError(x) => return Err(x),
                _ => panic!("Unable to decode image file")
            }
        };
        
        let image_info = reader.info();
        self.width = image_info.width as usize;
        self.height = image_info.height as usize;

     ...

        unsafe {
            gl::TexImage2D(gl::TEXTURE_2D, 
                0,
                gl::RGBA8 as i32,
                self.width as GLsizei,
                self.height as GLsizei,
                0,
                gl::RGBA,
                gl::UNSIGNED_BYTE,
                pixels.as_ptr() as *const GLvoid);
       }

I'm guessing that at some point, the in-memory representation of the image changes from RGBA? This seems like user error at this point so I'll focus on trying to fix my work, but let me know if it's worth creating a test case.

from image-png.

RandomInsano avatar RandomInsano commented on August 27, 2024

Fixed by setting transformations on the decoder:

        decoder.set_transformations(Transformations::ALPHA);

Sorry for the noise all! I've been pretty happy with this crate so far, keep up the great work!

from image-png.

Related Issues (20)

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.