Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glaciall-bitmap

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glaciall-bitmap

Manipulate bitmap image with pure JavaScript, and can be base64 format to display on web

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-45%
Maintainers
1
Weekly downloads
 
Created
Source

jsBitmap

基于Javascript的bitmap处理,并且将位图输出为base64编码以便于浏览器进行显示,代码超精简,低内存占用。

Install

npm install --save glaciall-bitmap

Usage

import {
    BitMap,
} from 'glaciall-bitmap';

export class YourReactClass extends React.PureComponent {
    constructor(props, ctx) {
        super(props, ctx);
        this.bmp = new BitMap();
        this.bmp.fromBase64(props.base64Bmp.replace(/^data:image\/bmp;base64,/, ''));
    }
}

API参考

一、Bitmap.create(width, height, bgcolor)
    创建一个width x height像素大小的位图,底色为bgcolor所代表的颜色。
    如:bitmap.create(10, 10, 0xff0000); // 创建一个10 x 10像素的底色为红色的位图

二、Bitmap.toBase64()
    将位图输出为base64编码的带datauri头(data:image/bmp;base64,)的字符串,以便于在浏览器里显示。
    如:document.getElementById('img1').src = bitmap.toBase64();

三、Bitmap.fromBase64()
    自图像的BASE64编码中恢复位图数据,目前只支持24位色的BMP位图数据。
    如:bitmap.fromBase64('Qk06AAAAAAAAADYAAAAoAAAAAQAAAAEAAAABABgAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==');

四、Bitmap.setBitmapBytes(val, idx, length)
    修改bitmap位图数据的第idx位置起的length字节为val值。

五、Bitmap.getBitmapBytes(idx, length)
    获取bitmap位图数据的第idx位置起的length个字节的值,返回值为数组。

六、Bitmap.setHeaderValue(attribute, headerValue)
    设置attribute头属性的值为headerValue,attribute必须为BitMapFormat的成员属性,需要提供offset、length等属性值。
    如:bitmap.setHeaderValue(BitmapFormat.biWidth, 500); // 设置位图的宽度为500像素值

七、Bitmap.getHeaderValue(attribute)
    获取位图attribute头属性的值,attribute必须为BitmapFormat的成员属性,需要提供offset、length等属性值,返回的是经过Endian转换后的实际整数值。

八、Bitmap.setPixel(x, y, color)
    设置位图的(x, y)位置的像素值为color。

九、Bitmap.getPixel(x, y)
    获取位图的(x, y)位置的RGB值,返回的内容为[ rr, gg, bb ]的数组内容

PS

glaciall authorized flyskywhy to publish glaciall-bitmap on npm.

Keywords

FAQs

Package last updated on 21 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc