#bitmap #bmp #decoding #image

bmp_rs

Microsoft bmp 文件的位图文件解码器

8 个版本

使用旧的 Rust 2015

0.0.9 2018年2月24日
0.0.6 2018年2月22日
0.0.3 2017年9月25日
0.0.2 2017年8月27日

#868图像

每月21次下载

Apache-2.0

33KB
737

bmp_rs

Microsoft bmp 文件的位图文件解码器。

开发状态

以下是一个大致的列表,列出了已支持或将来将支持的特性

  • 1位位图
  • 4位无压缩位图
  • 4位压缩位图
  • 8位无压缩位图
  • 8位压缩位图
  • 16位位图
  • 24位位图
  • 32位位图
  • Microsoft BMP 版本 1 头部
  • Microsoft BMP 版本 2 头部
  • Microsoft BMP 版本 3 头部
  • Microsoft BMP 版本 4 头部
  • Microsoft BMP 版本 5 头部
  • IBM OS/2 1.x BMP 头部(32k x 32k 限制)
  • IBM OS/2 2.x BMP 头部
  • OS/2 位图数组类型
  • OS/2 彩色图标类型
  • OS/2 彩色指针类型
  • OS/2 结构图标类型
  • OS/2 指针类型
  • 扩展解码,返回头部数据
  • 位图编码
  • 测试套件
  • 文档
  • 示例

示例

use std::fs::File;
use bmp_rs::{
    Result,
    Decoder,
};

struct ImageDecoder {
    // Your builder type that is able to construct an image
}

struct Image {
    // Your image type that represents a bitmap
}

impl Decoder for ImageDecoder {
    type TResult = Image; // Your image type

    fn set_size( &mut self, width: u32, height: u32 ) {
        // Set image size
    }

    fn set_pixel( &mut self, x: u32, y: u32, r: u8, g: u8, b: u8, a: u8 ) {
        // Set a specific pixel within that image to the given color
    }

    fn build( &mut self ) -> Result<Self::TResult> {
        // Build and return your final image
        Ok ( Image { } )
    }
}

fn main() {
    let mut file = File::open( "image.bmp" ).unwrap();
    let image = bmp_rs::decode( &mut file, ImageDecoder { } );
    // Do something with your image
}

许可

LICENSE 文件。

依赖

~165KB