144 lines
5.4 KiB
JavaScript
144 lines
5.4 KiB
JavaScript
// Metro module 4809 (f4810).
|
|
import { getStringFromDataView, getNullTerminatedStringFromDataView } from "./Module4802";
|
|
import Module4805 from "./Module4805";
|
|
let c2952_3, c2952_4, c2952_5, c2952_6, c2952_7, c2952_8, c2952_9, c2952_10, c2952_11, c2952_12, c2952_13, c2952_14, c2952_15, c2952_16;
|
|
const r12 = {
|
|
isPngFile: function isPngFile(a0) {
|
|
return !!a0 && getStringFromDataView(a0, 0, c2952_3.length) === c2952_3;
|
|
},
|
|
findPngOffsets: function findPngOffsets(a0, a1) {
|
|
let r37, r185, byteLength, byteLength2;
|
|
const r13 = {
|
|
hasAppMarkers: false
|
|
};
|
|
let length = c2952_3.length;
|
|
if (length + c2952_4 + c2952_5 <= a0.byteLength) {
|
|
do {
|
|
L39: {
|
|
r37 = length;
|
|
if (Module4805.USE_PNG_FILE && getStringFromDataView(a0, r37 + c2952_7, c2952_5) === "IHDR") {
|
|
r13.hasAppMarkers = true;
|
|
r13.pngHeaderOffset = r37 + c2952_8;
|
|
} else {
|
|
if (Module4805.USE_XMP && getStringFromDataView(a0, r37 + c2952_7, c2952_5) === c2952_11 && getStringFromDataView(a0, r37 + c2952_8, c2952_9.length) === c2952_9) {
|
|
const r150 = r37 + (c2952_8 + c2952_9.length + 1 + 1);
|
|
const r152 = r150 < a0.byteLength;
|
|
let r1 = 0;
|
|
let r153 = r150;
|
|
let r154 = 0;
|
|
let dataOffset = r153;
|
|
if (r152) {
|
|
do {
|
|
const uint82 = a0.getUint8(r153);
|
|
const r2 = r1;
|
|
const r158 = r153;
|
|
const r0 = uint82 === 0 ? r2 + 1 : r2;
|
|
const r159 = r158 + 1;
|
|
r154 = r0;
|
|
dataOffset = r159;
|
|
if (!(r0 < 2)) {
|
|
break;
|
|
}
|
|
byteLength = a0.byteLength;
|
|
r1 = r0;
|
|
r153 = r159;
|
|
r154 = r1;
|
|
dataOffset = r153;
|
|
} while (dataOffset < byteLength);
|
|
}
|
|
if (r154 < 2) {
|
|
dataOffset = void 0;
|
|
}
|
|
if (dataOffset === void 0) {
|
|
break L39;
|
|
}
|
|
r13.hasAppMarkers = true;
|
|
r13.xmpChunks = [{
|
|
dataOffset,
|
|
length: a0.getUint32(r37 + c2952_6) - (dataOffset - (r37 + c2952_8))
|
|
}];
|
|
break L39;
|
|
}
|
|
const stringFromDataView = getStringFromDataView(a0, r37 + c2952_7, c2952_5);
|
|
if (stringFromDataView === c2952_10 || stringFromDataView === c2952_11 || stringFromDataView === c2952_12 && a1) {
|
|
r13.hasAppMarkers = true;
|
|
const stringFromDataView2 = getStringFromDataView(a0, r37 + c2952_7, c2952_5);
|
|
if (!r13.pngTextChunks) {
|
|
r13.pngTextChunks = [];
|
|
}
|
|
r13.pngTextChunks.push({
|
|
length: a0.getUint32(r37 + c2952_6),
|
|
type: stringFromDataView2,
|
|
offset: r37 + c2952_8
|
|
});
|
|
} else if (getStringFromDataView(a0, r37 + c2952_7, c2952_5) === c2952_15) {
|
|
r13.hasAppMarkers = true;
|
|
r13.tiffHeaderOffset = r37 + c2952_8;
|
|
} else {
|
|
if (Module4805.USE_ICC && a1 && getStringFromDataView(a0, r37 + c2952_7, c2952_5) === c2952_16) {
|
|
r13.hasAppMarkers = true;
|
|
const uint32 = a0.getUint32(r37 + c2952_6);
|
|
const r29 = r37 + c2952_8;
|
|
const nullTerminatedStringFromDataView = getNullTerminatedStringFromDataView(a0, r29);
|
|
const r115 = r29 + (nullTerminatedStringFromDataView.length + 1);
|
|
const uint8 = a0.getUint8(r115);
|
|
if (!r13.iccChunks) {
|
|
r13.iccChunks = [];
|
|
}
|
|
const offset = r115 + 1;
|
|
r13.iccChunks.push({
|
|
offset,
|
|
length: uint32 - (offset - r29),
|
|
chunkNumber: 1,
|
|
chunksTotal: 1,
|
|
profileName: nullTerminatedStringFromDataView,
|
|
compressionMethod: uint8
|
|
});
|
|
break L39;
|
|
}
|
|
if ([c2952_13, c2952_14].includes(getStringFromDataView(a0, r37 + c2952_7, c2952_5))) {
|
|
r13.hasAppMarkers = true;
|
|
if (!r13.pngChunkOffsets) {
|
|
r13.pngChunkOffsets = [];
|
|
}
|
|
r13.pngChunkOffsets.push(r37 + c2952_6);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const r182 = r37 + (a0.getUint32(r37 + c2952_6) + c2952_4 + c2952_5 + 4);
|
|
byteLength2 = a0.byteLength;
|
|
r185 = r182 + c2952_4 + c2952_5;
|
|
length = r182;
|
|
} while (r185 <= byteLength2);
|
|
}
|
|
return r13;
|
|
}
|
|
};
|
|
c2952_3 = "PNG\r\n\x1a\n";
|
|
c2952_4 = 4;
|
|
c2952_5 = 4;
|
|
c2952_6 = 0;
|
|
c2952_7 = 4;
|
|
c2952_8 = 8;
|
|
c2952_9 = "XML:com.adobe.xmp\x00";
|
|
c2952_10 = "tEXt";
|
|
c2952_11 = "iTXt";
|
|
c2952_12 = "zTXt";
|
|
c2952_13 = "pHYs";
|
|
c2952_14 = "tIME";
|
|
c2952_15 = "eXIf";
|
|
c2952_16 = "iCCP";
|
|
export default r12;
|
|
export const PNG_CHUNK_TYPE_SIZE = 4;
|
|
export const PNG_CHUNK_LENGTH_OFFSET = 0;
|
|
export const PNG_CHUNK_TYPE_OFFSET = 4;
|
|
export const PNG_CHUNK_DATA_OFFSET = 8;
|
|
export const TYPE_TEXT = "tEXt";
|
|
export const TYPE_ITXT = "iTXt";
|
|
export const TYPE_ZTXT = "zTXt";
|
|
export const TYPE_PHYS = "pHYs";
|
|
export const TYPE_TIME = "tIME";
|
|
export const TYPE_EXIF = "eXIf";
|
|
export const TYPE_ICCP = "iCCP";
|