60e2149072
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date) - Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class - Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting - Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states - Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions - Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares) - Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline - Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements - Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations - Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary - Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds All tests follow AAA pattern and use data-testid selectors matching Angular version. Total: 245 tests across 10 feature suites.
94 lines
2.3 KiB
JavaScript
94 lines
2.3 KiB
JavaScript
"use strict";
|
|
|
|
function dePalette(indata, outdata, width, height, palette) {
|
|
let pxPos = 0;
|
|
// use values from palette
|
|
for (let y = 0; y < height; y++) {
|
|
for (let x = 0; x < width; x++) {
|
|
let color = palette[indata[pxPos]];
|
|
|
|
if (!color) {
|
|
throw new Error("index " + indata[pxPos] + " not in palette");
|
|
}
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = color[i];
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
function replaceTransparentColor(indata, outdata, width, height, transColor) {
|
|
let pxPos = 0;
|
|
for (let y = 0; y < height; y++) {
|
|
for (let x = 0; x < width; x++) {
|
|
let makeTrans = false;
|
|
|
|
if (transColor.length === 1) {
|
|
if (transColor[0] === indata[pxPos]) {
|
|
makeTrans = true;
|
|
}
|
|
} else if (
|
|
transColor[0] === indata[pxPos] &&
|
|
transColor[1] === indata[pxPos + 1] &&
|
|
transColor[2] === indata[pxPos + 2]
|
|
) {
|
|
makeTrans = true;
|
|
}
|
|
if (makeTrans) {
|
|
for (let i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = 0;
|
|
}
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
function scaleDepth(indata, outdata, width, height, depth) {
|
|
let maxOutSample = 255;
|
|
let maxInSample = Math.pow(2, depth) - 1;
|
|
let pxPos = 0;
|
|
|
|
for (let y = 0; y < height; y++) {
|
|
for (let x = 0; x < width; x++) {
|
|
for (let i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = Math.floor(
|
|
(indata[pxPos + i] * maxOutSample) / maxInSample + 0.5
|
|
);
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = function (indata, imageData, skipRescale = false) {
|
|
let depth = imageData.depth;
|
|
let width = imageData.width;
|
|
let height = imageData.height;
|
|
let colorType = imageData.colorType;
|
|
let transColor = imageData.transColor;
|
|
let palette = imageData.palette;
|
|
|
|
let outdata = indata; // only different for 16 bits
|
|
|
|
if (colorType === 3) {
|
|
// paletted
|
|
dePalette(indata, outdata, width, height, palette);
|
|
} else {
|
|
if (transColor) {
|
|
replaceTransparentColor(indata, outdata, width, height, transColor);
|
|
}
|
|
// if it needs scaling
|
|
if (depth !== 8 && !skipRescale) {
|
|
// if we need to change the buffer size
|
|
if (depth === 16) {
|
|
outdata = Buffer.alloc(width * height * 4);
|
|
}
|
|
scaleDepth(indata, outdata, width, height, depth);
|
|
}
|
|
}
|
|
return outdata;
|
|
};
|