Updated png and bmp related-libs, Updated home page and sidebar

Update sidebar.yml, home.yml, and 7 more files...
This commit is contained in:
2025-08-25 00:03:01 +02:00
parent a20b45d86e
commit 41286a8253
9 changed files with 185 additions and 65 deletions

1
static/resources/Externals/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.svg

View File

@@ -1,6 +1,7 @@
import {initCore} from "../../js/nibblepoker-core.mjs"
import {parsePngFile} from "../../libs/png-utils.mjs";
import {parseBmpFile} from "../../libs/bmp-utils.mjs";
{
initCore();
@@ -16,12 +17,18 @@ import {parsePngFile} from "../../libs/png-utils.mjs";
console.log(files);
parsePngFile(files[0]).then(pngFile => {
console.log(pngFile);
if(files[0].name.endsWith(".png")) {
parsePngFile(files[0]).then(pngFile => {
console.log(pngFile);
console.log(pngFile.getImageHeaderChunk().getWidth());
console.log(pngFile.getImageHeaderChunk().getHeight());
});
} else if(files[0].name.endsWith(".bmp")) {
parseBmpFile(files[0]).then(bmpFile => {
console.log(bmpFile);
});
}
console.log(pngFile.getImageHeaderChunk().getWidth());
console.log(pngFile.getImageHeaderChunk().getHeight());
});
});
};
}

View File

@@ -0,0 +1,57 @@
import {loadFileAsUint8Array} from "./file-utils.mjs";
import {peekUInt32BE, peekUInt16BE} from "./data-utils.mjs";
/*export const test = {
WINDOWS: "BM",
OS2_STRUCT_BITMAP_ARRAY: "BA",
OS2_STRUCT_COLOR_ICON: "CI",
OS2_CONST_COLOR_POINTER: "CP",
OS2_STRUCT_ICON: "IC",
OS2_POINTER: "PT",
}*/
export class BmpHeader {
/** @type {Uint8Array} */
data;
/**
* @param byteArray {Uint8Array|null}
*/
constructor(byteArray) {
if(byteArray === null || byteArray === undefined) {
this.data = new Uint8Array(14);
} else {
this.data = byteArray;
}
}
getSignature() {
return peekUInt16BE(this.data, 0);
}
getFileSize() {
return peekUInt32BE(this.data, 2);
}
getReserved() {
return peekUInt32BE(this.data, 6);
}
getDataOffset() {
return peekUInt32BE(this.data, 10);
}
}
export class CrudeBmpFile {
constructor(file = null, fileData = null) {
this.originalFile = file;
}
}
export function parseBmpFile(file) {
return loadFileAsUint8Array(file).then(byteBuffer => {
return new CrudeBmpFile(file, byteBuffer);
});
}

View File

@@ -23,6 +23,34 @@ export function areUintArraysEqual(array1, array2) {
return true;
}
/**
* Peeks a UInt16 from the given data at the given offset in Big-Endian.
* @param data {Uint8Array} - Data to read from.
* @param offset {number} - Offset to read from in the given `data`.
* @return {number} The peeked number.
* @throws RangeError If the given offset is too close or over the end of the data.
*/
export function peekUInt16BE(data, offset = 0) {
if(offset + 2 > data.length) {
throw new RangeError(`Offset is too far into the given data ! (${offset} & ${data.length})`);
}
return new DataView(data.buffer, offset, 2).getUint16(0, false);
}
/**
* Peeks a UInt16 from the given data at the given offset in Little-Endian.
* @param data {Uint8Array} - Data to read from.
* @param offset {number} - Offset to read from in the given `data`.
* @return {number} The peeked number.
* @throws RangeError If the given offset is too close or over the end of the data.
*/
export function peekUInt16LE(data, offset = 0) {
if(offset + 2 > data.length) {
throw new RangeError(`Offset is too far into the given data ! (${offset} & ${data.length})`);
}
return new DataView(data.buffer, offset, 2).getUint16(0, true);
}
/**
* Peeks a UInt32 from the given data at the given offset in Big-Endian.
* @param data {Uint8Array} - Data to read from.