-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
export class IcoFileHeader { | ||
reserved: number | ||
type: number | ||
count: number | ||
readonly reserved: number | ||
readonly type: number | ||
readonly count: number | ||
|
||
constructor(reserved = 0, type = 1, count = 0) { | ||
this.reserved = reserved | ||
this.type = type | ||
this.count = count | ||
} | ||
|
||
/** | ||
* Create ICO file header from the buffer. | ||
* @param buffer The ICO file header buffer. | ||
*/ | ||
static from(buffer: Buffer): IcoFileHeader { | ||
const reserved = buffer.readUInt16LE(0) | ||
const type = buffer.readUInt16LE(2) | ||
const count = buffer.readUInt16LE(4) | ||
return new IcoFileHeader(reserved, type, count) | ||
} | ||
|
||
get data(): Buffer { | ||
const buffer = Buffer.alloc(6) | ||
buffer.writeUInt16LE(this.reserved, 0) | ||
buffer.writeUInt16LE(this.type, 2) | ||
buffer.writeUInt16LE(this.count, 4) | ||
return buffer | ||
} | ||
|
||
set data(buffer) { | ||
this.reserved = buffer.readUInt16LE(0) | ||
this.type = buffer.readUInt16LE(2) | ||
this.count = buffer.readUInt16LE(4) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.