decord/source/utils/native/ImageUtils.tsx

131 lines
4.3 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 1493
// Function ID: 1494
2026-07-29 08:29:29 +00:00
// Name: getSrcWithWidthAndHeight
2026-08-15 05:55:55 +00:00
// Dependencies: [32, 17, 676, 1470, 1494, 1484, 1471, 1896, 12, 1438, 1435, 2]
2026-07-20 16:05:17 +00:00
// Exports: getMobileOptimizedSrc, getPaletteForAvatarMobile
2026-08-15 05:55:55 +00:00
// Module 1493 (getSrcWithWidthAndHeight)
2026-08-24 06:08:38 +00:00
import getAvatarURL from "getAvatarURL" /* 1435 */;
import ensureAvatarSource from "ensureAvatarSource" /* 1438 */;
import items2 from "items" /* 1471 */;
import parseDefault from "parse" /* 1484 */;
import useWindowDimensions from "useWindowDimensions" /* 1494 */;
import closure_3 from "_slicedToArray" /* 32 */;
import get_ActivityIndicator from "get ActivityIndicator" /* 17 */;
import { MEDIA_PROXY_MAX_TARGET_RESOLUTION as closure_6 } from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function getSrcWithWidthAndHeight(animated) {
2026-07-29 08:29:29 +00:00
({ src, sourceWidth, sourceHeight, targetWidth, targetHeight, format } = animated);
2026-07-20 16:05:17 +00:00
if (format === undefined) {
format = null;
}
let flag = animated.animated;
if (flag === undefined) {
flag = false;
}
const tmp = callback(src.split("?"), 2);
const items = [tmp[0], ];
2026-08-24 06:08:38 +00:00
let obj = parseDefault;
2026-07-20 16:05:17 +00:00
items[1] = obj.parse(tmp[1]);
2026-08-24 06:08:38 +00:00
[tmp5, tmp6] = callback(items, 2);
if (regex2.test(tmp5)) {
2026-07-29 08:29:29 +00:00
tmp6.format = "webp";
2026-07-20 16:05:17 +00:00
} else if (null != format) {
2026-07-29 08:29:29 +00:00
tmp6.format = format;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (targetWidth > closure_6) {
targetWidth = tmp8;
}
if (targetHeight > closure_6) {
targetHeight = tmp8;
}
if (targetWidth !== sourceWidth) {
2026-08-15 05:55:55 +00:00
const tmp9 = (function getAttachmentLadderConfig(arg0) {
2026-07-29 08:29:29 +00:00
try {
const obj = { location: null };
obj[0] = "native/ImageUtils.getSrcWithWidthAndHeight";
2026-08-15 05:55:55 +00:00
const attachmentImageLadderConfig = callback(table[3]).getAttachmentImageLadderConfig(obj);
let tmp5 = null;
if (true === attachmentImageLadderConfig.enabled) {
tmp5 = attachmentImageLadderConfig;
}
return tmp5;
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-08-15 05:55:55 +00:00
return null;
2026-07-20 16:05:17 +00:00
}
2026-08-15 05:55:55 +00:00
})("native/ImageUtils.getSrcWithWidthAndHeight");
let size = { width: null, height: null };
size[0] = targetWidth;
size[1] = targetHeight;
if (null != tmp9) {
2026-07-31 08:44:05 +00:00
obj = { targetWidth: null, targetHeight: null, sourceWidth: null, sourceHeight: null, maxUpscale: null };
2026-07-29 08:29:29 +00:00
obj[0] = targetWidth;
obj[1] = targetHeight;
obj[2] = sourceWidth;
obj[3] = sourceHeight;
2026-08-24 06:08:38 +00:00
const obj2 = items2;
obj[4] = items2.getSnapDownMaxUpscale(tmp9, tmp2(1896)());
2026-08-15 05:55:55 +00:00
size = obj2.snapAttachmentDimensions(obj);
2026-08-24 06:08:38 +00:00
const obj4 = items2;
2026-07-29 08:29:29 +00:00
}
2026-08-15 05:55:55 +00:00
if (!tmp12) {
2026-07-29 08:29:29 +00:00
tmp6.width = size.width | 0;
tmp6.height = size.height | 0;
2026-07-20 16:05:17 +00:00
}
2026-08-15 05:55:55 +00:00
tmp12 = size.width === sourceWidth && size.height === sourceHeight;
2026-07-20 16:05:17 +00:00
}
if (flag) {
2026-07-29 08:29:29 +00:00
tmp6.animated = true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp2Result = tmp2(12);
let text = tmp5;
if (!tmp2Result.isEmpty(tmp6)) {
2026-08-15 05:55:55 +00:00
tmp2Result = tmp2(1484);
text = `${tmp5}?${obj6.stringify(tmp6)}`;
2026-07-20 16:05:17 +00:00
}
return text;
}
function getMobileOptimizedSrc(proxy_url, width, height, png) {
let tmp = png;
if (png === undefined) {
tmp = null;
}
let num = 1;
2026-08-24 06:08:38 +00:00
if (regex.test(proxy_url)) {
2026-07-20 16:05:17 +00:00
num = 0.3;
}
2026-08-24 06:08:38 +00:00
let obj = useWindowDimensions;
2026-07-20 16:05:17 +00:00
const size = obj.getWindowDimensions();
const result = store.getPixelSizeForLayoutSize(size.width) * num;
const bound = Math.min(width > height ? result / width : store.getPixelSizeForLayoutSize(size.height / 2) * num / height, 1);
let rounded1 = height;
2026-07-29 08:29:29 +00:00
let rounded = width;
2026-07-20 16:05:17 +00:00
if (bound < 1) {
const _Math = Math;
rounded = Math.ceil(width * bound);
const _Math2 = Math;
rounded1 = Math.ceil(height * bound);
}
obj = { src: proxy_url, sourceWidth: width, sourceHeight: height, targetWidth: rounded, targetHeight: rounded1, format: tmp };
return getSrcWithWidthAndHeight(obj);
}
2026-07-29 08:29:29 +00:00
function getPaletteForAvatarMobile(closure_0) {
2026-08-24 06:08:38 +00:00
const obj = ensureAvatarSource;
2026-07-23 10:11:24 +00:00
ImageManager = ImageManager.ImageManager;
2026-08-24 06:08:38 +00:00
return ImageManager.getDominantColors(obj.ensureAvatarSource(getAvatarURL.makeSource(closure_0)));
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
({ NativeModules: c4, PixelRatio: c5 } = get_ActivityIndicator);
2026-07-20 16:05:17 +00:00
const tmp3 = /\.(gif)$/i;
2026-08-24 06:08:38 +00:00
const re7 = tmp3;
const tmp4 = /\.(avif)$/i;
const re8 = tmp4;
let result = require("set").fileFinishedImporting("utils/native/ImageUtils.tsx");
2026-07-20 16:05:17 +00:00
export default { getMobileOptimizedSrc, getPaletteForAvatarMobile };
export const GIF_RE = tmp3;
export const AVIF_RE = tmp4;
export { getSrcWithWidthAndHeight };
export { getMobileOptimizedSrc };
export { getPaletteForAvatarMobile };