Giter Club home page Giter Club logo

rust-bmp's People

Contributors

electriccoffee avatar gabrielmajeri avatar jonas-schievink avatar okey avatar ottaviohartman avatar posixphreak avatar sondrele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rust-bmp's Issues

Doesn't handle assigning pixels out of order

I was writing some multithreaded code using channels, and was getting the values for each pixel in a non-deterministic order. When I attempted to just use the set_pixel function to just write each pixel's value to the image, I got very strange results. I eventually realized that set_pixel uses the Vec::insert method, which shifts all elements after the one inserted. This works fine for sequentially assigning the pixels, but breaks when assigning pixels out of order.

u32 as index is incompatible with rust vectors

Library uses u32 for image size and image coords.
Most libraries use usize as index and size.
So there is a lot of boilerplase cast operators while working with this crate.
Could u change coordinate and size to usize, please?

Expose Read/Write interface instead of filenames

A lot of the time you'll be working on images entirely in-memory and don't want to write to the file system. Is it possible to expose an interface which reads from an io::Reader and writes to an io::Write? You probably already work with something like this internally, so it shouldn't require much extra work.

i.e. Something like this:

use std::io::{Read, Write};

fn from_reader<R: Read>(source: R) -> Result<Image> { /* ... */ }
fn to_writer<W: Write>(writer: W, image: Image) -> Result<()> { /* ... */ }

Merge into Image

You should think about copying or merging code from this repository into PistonDevelopers/image. It attempts to be the end-all image library, and it could use BMP support.

error: unstable feature

Hi Sondre,

It's my first try on Rust, after doing an "Hello world" I've try to use your lib: I'm really a noob, it may be a problem on my side, not yours.

Having "rustc 1.0.0-beta.3", I've done as on your example. I've got this error:

> cargo build
   Compiling bmp v0.1.2 (https://github.com/sondrele/rust-bmp#060fb24d)
C:\Users\Yop\.cargo\git\checkouts\rust-bmp-3a7f890ae607b0ba\master\src\lib.rs:3:1: 3:25 error: unstable feature
C:\Users\Yop\.cargo\git\checkouts\rust-bmp-3a7f890ae607b0ba\master\src\lib.rs:3 #![feature(collections)]
                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
error: aborting due to previous error
Could not compile `bmp`.

To learn more, run the command again with --verbose.

BMP is rotated 90 degrees when copying from normal buffer

When creating a BMP from a normal image buffer, the image ends up rotated 90 degrees. This is due to how BMP is defined, but rust-bmp makes no reference to this.

rust-bmp should state clearly the coordinate convention its API follows.

Do not panic on save() failure

It's inappropriate to panic on a failure to write a file, since the consumer of this library may want to handle that error. Why not just return the underlying IoResult?

Release build produces corrupt BMP headers

For some reason I'm not sure why, binaries generated with --release parameter produce corrupt bmp headers. I suspect this could be a Rust compiler/LLVM bug, but I haven't had time to debug. I've later found out that https://github.com/pistondevelopers/image also corrupts the whole PNG file with release builds. Debug builds are again OK.

Sample code:

extern crate bmp;

fn main() {
    let mut img = bmp::Image::new(100, 100);
    for y in 0..100 {
        for x in 0..100 {
            img.set_pixel(x, y, bmp::Pixel {r: 0, g: 206, b: 209});
        }
    }
    img.save("test.bmp").unwrap();
}

Output:

$ cargo run && xxd test.bmp | head
     Running `target/debug/bug`
0000000: 424d 6675 0000 0000 0000 3600 0000 2800  BMfu......6...(.
0000010: 0000 6400 0000 6400 0000 0100 1800 0000  ..d...d.........
0000020: 0000 3075 0000 e803 0000 e803 0000 0000  ..0u............
0000030: 0000 0000 0000 d1ce 00d1 ce00 d1ce 00d1  ................
0000040: ce00 d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce  ................
0000050: 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1 ce00  ................
0000060: d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1  ................
0000070: ce00 d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce  ................
0000080: 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1 ce00  ................
0000090: d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1  ................
$ cargo run --release && xxd test.bmp | head
     Running `target/release/bug`
0000000: 424d 0200 0000 0000 0000 0200 0000 0400  BM..............
0000010: 0000 0400 0000 0400 0000 0000 0000 0200  ................
0000020: 0000 0400 0000 0400 0000 0400 0000 0400  ................
0000030: 0000 0400 0000 d1ce 00d1 ce00 d1ce 00d1  ................
0000040: ce00 d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce  ................
0000050: 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1 ce00  ................
0000060: d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1  ................
0000070: ce00 d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce  ................
0000080: 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1 ce00  ................
0000090: d1ce 00d1 ce00 d1ce 00d1 ce00 d1ce 00d1  ................

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.