- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
90 lines
2.2 KiB
JavaScript
90 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
function dePalette(indata, outdata, width, height, palette) {
|
|
var pxPos = 0;
|
|
// use values from palette
|
|
for (var y = 0; y < height; y++) {
|
|
for (var x = 0; x < width; x++) {
|
|
var color = palette[indata[pxPos]];
|
|
|
|
if (!color) {
|
|
throw new Error('index ' + indata[pxPos] + ' not in palette');
|
|
}
|
|
|
|
for (var i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = color[i];
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
function replaceTransparentColor(indata, outdata, width, height, transColor) {
|
|
var pxPos = 0;
|
|
for (var y = 0; y < height; y++) {
|
|
for (var x = 0; x < width; x++) {
|
|
var 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 (var i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = 0;
|
|
}
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
function scaleDepth(indata, outdata, width, height, depth) {
|
|
var maxOutSample = 255;
|
|
var maxInSample = Math.pow(2, depth) - 1;
|
|
var pxPos = 0;
|
|
|
|
for (var y = 0; y < height; y++) {
|
|
for (var x = 0; x < width; x++) {
|
|
for (var i = 0; i < 4; i++) {
|
|
outdata[pxPos + i] = Math.floor((indata[pxPos + i] * maxOutSample) / maxInSample + 0.5);
|
|
}
|
|
pxPos += 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = function(indata, imageData) {
|
|
|
|
var depth = imageData.depth;
|
|
var width = imageData.width;
|
|
var height = imageData.height;
|
|
var colorType = imageData.colorType;
|
|
var transColor = imageData.transColor;
|
|
var palette = imageData.palette;
|
|
|
|
var 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) {
|
|
// if we need to change the buffer size
|
|
if (depth === 16) {
|
|
outdata = new Buffer(width * height * 4);
|
|
}
|
|
scaleDepth(indata, outdata, width, height, depth);
|
|
}
|
|
}
|
|
return outdata;
|
|
};
|