Comparing version 0.2.1 to 0.2.2
# Changelog | ||
## v0.2.2 | ||
- Fix width and height usage for icon group, especially when loading from an icon file (#5) | ||
## v0.2.1 | ||
@@ -4,0 +8,0 @@ |
@@ -103,3 +103,3 @@ "use strict"; | ||
if (view.getUint32(dataOffset, true) === 0x28) { | ||
data = IconItem_1.default.from(bin, dataOffset, dataSize); | ||
data = IconItem_1.default.from(width, height, bin, dataOffset, dataSize); | ||
} | ||
@@ -106,0 +106,0 @@ else { |
import BitmapInfo from './BitmapInfo'; | ||
export default class IconItem { | ||
/** | ||
* Bitmap header data (`BITMAPINFOHEADER`) | ||
*/ | ||
readonly bitmapInfo: BitmapInfo; | ||
/** | ||
* Horizontal size of the icon in pixel (overrides `bitmapInfo.width`). | ||
* If `null` is specified, `bitmapInfo.width` will be used. | ||
*/ | ||
width: number | null; | ||
/** | ||
* Vertical size of the icon in pixel (overrides `bitmapInfo.height`). | ||
* If `null` is specified, `bitmapInfo.height` will be used. | ||
*/ | ||
height: number | null; | ||
/** | ||
* Bitmap pixel data | ||
*/ | ||
pixels: ArrayBuffer; | ||
/** | ||
* Bitmap pixel data used for mask | ||
* (the data will be appended immediately after `pixels` when generating icon binary) | ||
*/ | ||
masks: ArrayBuffer | null; | ||
private constructor(); | ||
/** | ||
* Generates `IconItem` instance from bitmap data binary. | ||
* @param bin binary data containing the bitmap data | ||
* @param byteOffset byte offset of `bin` referring the bitmap data | ||
* @param byteLength available byte length for `bin` (from the offset `byteOffset`) | ||
*/ | ||
static from(bin: ArrayBuffer, byteOffset?: number, byteLength?: number): IconItem; | ||
/** | ||
* Generates `IconItem` instance from bitmap data binary width actual icon size (width and height). | ||
* @param width icon width | ||
* @param height icon height | ||
* @param bin binary data containing the bitmap data | ||
* @param byteOffset byte offset of `bin` referring the bitmap data | ||
* @param byteLength available byte length for `bin` (from the offset `byteOffset`) | ||
*/ | ||
static from(width: number, height: number, bin: ArrayBuffer, byteOffset?: number, byteLength?: number): IconItem; | ||
isIcon(): this is IconItem; | ||
@@ -9,0 +44,0 @@ isRaw(): false; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var IconItem = /** @class */ (function () { | ||
function IconItem(bin, byteOffset, byteLength) { | ||
function IconItem(width, height, bin, byteOffset, byteLength) { | ||
var view = new DataView(bin, byteOffset, byteLength); | ||
@@ -53,2 +53,4 @@ var totalSize = view.byteLength; | ||
} | ||
this.width = width; | ||
this.height = height; | ||
this.bitmapInfo = bi; | ||
@@ -71,4 +73,21 @@ var absWidthRound = functions_1.roundUp(Math.abs(bi.width), 8); | ||
} | ||
IconItem.from = function (bin, byteOffset, byteLength) { | ||
return new IconItem(bin, byteOffset, byteLength); | ||
IconItem.from = function (arg1, arg2, arg3, byteOffset, byteLength) { | ||
var width; | ||
var height; | ||
var bin; | ||
if (typeof arg3 === 'object') { | ||
// second overload | ||
width = arg1; | ||
height = arg2; | ||
bin = arg3; | ||
} | ||
else { | ||
// first overload | ||
width = null; | ||
height = null; | ||
bin = arg1; | ||
byteOffset = arg2; | ||
byteLength = arg3; | ||
} | ||
return new IconItem(width, height, bin, byteOffset, byteLength); | ||
}; | ||
@@ -75,0 +94,0 @@ IconItem.prototype.isIcon = function () { |
@@ -137,5 +137,21 @@ "use strict"; | ||
if (icon.isIcon()) { | ||
var width = icon.width, height = icon.height; | ||
if (width === null) { | ||
width = icon.bitmapInfo.width; | ||
} | ||
if (height === null) { | ||
height = icon.bitmapInfo.height; | ||
// if mask is specified, the icon height must be the half of bitmap height | ||
if (icon.masks !== null) { | ||
height = Math.floor(height / 2); | ||
} | ||
} | ||
return { | ||
base: icon, | ||
bm: icon.bitmapInfo, | ||
bm: { | ||
width: width, | ||
height: height, | ||
planes: icon.bitmapInfo.planes, | ||
bitCount: icon.bitmapInfo.bitCount | ||
}, | ||
bin: icon.generate(), | ||
@@ -142,0 +158,0 @@ id: 0 |
@@ -1,2 +0,2 @@ | ||
declare const _default: "0.2.1"; | ||
declare const _default: "0.2.2"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '0.2.1'; | ||
exports.default = '0.2.2'; |
{ | ||
"name": "resedit", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=10", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
173021
4060
0