feat: rootpage #16
@@ -67,18 +67,20 @@ const ico = () => {
|
||||
bitmap.writeUInt16LE(32, 14) // bits per pixel
|
||||
bitmap.writeUInt32LE(xorSize + maskSize, 20) // image size
|
||||
|
||||
// XOR bitmap: bottom-up rows of BGRA.
|
||||
// XOR bitmap: bottom-up rows of BGRA. With a null BACKGROUND the pixel stays
|
||||
// zeroed and alpha 0, which is how a 32bpp ICO carries transparency.
|
||||
let offset = 40
|
||||
for (let y = SIZE - 1; y >= 0; y--) {
|
||||
for (let x = 0; x < SIZE; x++) {
|
||||
const [r, g, b] = hex(colorAt(x, y) ?? '#000000')
|
||||
const color = colorAt(x, y)
|
||||
const [r, g, b] = color ? hex(color) : [0, 0, 0]
|
||||
bitmap[offset++] = b
|
||||
bitmap[offset++] = g
|
||||
bitmap[offset++] = r
|
||||
bitmap[offset++] = 0xff
|
||||
bitmap[offset++] = color ? 0xff : 0
|
||||
}
|
||||
}
|
||||
// AND mask stays zeroed: every pixel is opaque.
|
||||
// AND mask stays zeroed: 32bpp readers use the alpha channel instead.
|
||||
|
||||
const header = Buffer.alloc(6)
|
||||
header.writeUInt16LE(0, 0) // reserved
|
||||
|
||||
Reference in new issue
Block a user