glaciall-bitmap
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -153,2 +153,25 @@ var Base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); | ||
// 预先使用 getPixel() 生成RGB数值的二维数组,便于调用者稍后以之快速定位像素,因为查表的速度远高于即时计算 getPixel() | ||
// 返回的内容为[ [0xrrggbb, 0xrrggbb], [0xrrggbb, 0xrrggbb] ]的[[x维],[x维]]二维数组内容 | ||
// 如果位图原始数据被比如 setPixel() 修改了,则需要重新调用本函数来更新RGB二维数组 | ||
this.getRgbRect = function() | ||
{ | ||
let rect = []; | ||
for (let y = 0; y < this.height; y++) { | ||
let rectX = []; | ||
for (let x = 0; x < this.width; x++) { | ||
const p = this.getPixel(x, y); | ||
rectX.push((p[0] << 16) | (p[1] << 8) | p[2]); | ||
} | ||
rect.push(rectX); | ||
} | ||
return rect; | ||
} | ||
// 将 0xrrggbb 转换为 '#rrggbb' | ||
this.rgbToHexString = function(rgb) | ||
{ | ||
return '#' + (rgb & 0xFFFFFF).toString(16).padStart(6, '0'); | ||
} | ||
// 获取当前bitmap的datauri串,用于显示或发送到服务器端 | ||
@@ -207,2 +230,4 @@ this.toBase64 = function() | ||
this.height = this.getHeaderValue(BitMapFormat.biHeight); | ||
var biSizeImage = parseInt((this.width * 24 + 31) / 32) * 4 * this.height; | ||
_length_to_fit = biSizeImage / this.height - (this.width * 3); | ||
} | ||
@@ -209,0 +234,0 @@ } |
{ | ||
"name": "glaciall-bitmap", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Manipulate bitmap image with pure JavaScript, and can be base64 format to display on web", | ||
@@ -19,3 +19,4 @@ "main": "bitmap.js", | ||
"jsbitmap", | ||
"react" | ||
"react", | ||
"rgb" | ||
], | ||
@@ -22,0 +23,0 @@ "contributors": [ |
@@ -61,5 +61,13 @@ jsBitmap | ||
十、Bitmap.getRgbRect()<br/> | ||
预先使用 getPixel() 生成RGB数值的二维数组,便于调用者稍后以之快速定位像素,因为查表的速度远高于即时计算 getPixel()<br/> | ||
返回的内容为[ [0xrrggbb, 0xrrggbb], [0xrrggbb, 0xrrggbb] ]的[[x维],[x维]]二维数组内容<br/> | ||
如果位图原始数据被比如 setPixel() 修改了,则需要重新调用本函数来更新RGB二维数组<br/> | ||
十一、Bitmap.rgbToHexString(rgb)<br/> | ||
将 0xrrggbb 转换为 '#rrggbb'<br/> | ||
PS | ||
======== | ||
[glaciall](https://github.com/glaciall) [authorized](https://github.com/glaciall/jsBitmap/pull/2#issuecomment-566343119) [flyskywhy](https://github.com/flyskywhy) to publish glaciall-bitmap on npm. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22408
227
73