({ symbol, w, h, rgb565 })
| 929 | } |
| 930 | |
| 931 | function importRgb565ImageToDisplayKit({ symbol, w, h, rgb565 }) { |
| 932 | if (!Array.isArray(rgb565) || !rgb565.length) { |
| 933 | throw new Error("No RGB565 data to import."); |
| 934 | } |
| 935 | |
| 936 | const id = makeId(); |
| 937 | const x = Math.max(0, Math.round((dispWidth - w) / 2)); |
| 938 | const y = Math.max(0, Math.round((dispHeight - h) / 2)); |
| 939 | const previewUrl = rgb565ToDataUrl(w, h, rgb565); |
| 940 | |
| 941 | // Register asset (embedded by default for imported headers) |
| 942 | const assetId = "asset_" + Math.random().toString(36).slice(2, 10); |
| 943 | assets.push({ |
| 944 | id: assetId, |
| 945 | name: symbol || ("image_" + assetId), |
| 946 | kind: "image", |
| 947 | dataUrl: previewUrl, |
| 948 | sourceName: symbol || "", |
| 949 | width: w, |
| 950 | height: h, |
| 951 | rgb565: Array.from(rgb565), |
| 952 | }); |
| 953 | ensureAssetsDefaults(); |
| 954 | |
| 955 | const el = { |
| 956 | id, |
| 957 | type: "image", |
| 958 | x, |
| 959 | y, |
| 960 | w, |
| 961 | h, |
| 962 | text: "", |
| 963 | textSize: 2, |
| 964 | fillColor: "#ffffff", |
| 965 | strokeColor: "#ffffff", |
| 966 | textColor: "#000000", |
| 967 | value: 0, |
| 968 | imageName: symbol || ("img_" + id.replace(/[^a-zA-Z0-9_]/g, "_")), |
| 969 | imageWidth: w, |
| 970 | imageHeight: h, |
| 971 | rgb565, |
| 972 | previewUrl, |
| 973 | assetId, |
| 974 | font: getCurrentDriverMode() === "tft" ? DEFAULT_TFT_FONT : DEFAULT_U8G2_FONT |
| 975 | }; |
| 976 | |
| 977 | elements.push(el); |
| 978 | syncActiveScreenElements(); |
| 979 | selectedId = id; |
| 980 | updatePreviewSize(); |
| 981 | renderElements(); |
| 982 | updatePropsInputs(); |
| 983 | updateCode(); |
| 984 | renderAssets(); |
| 985 | pushHistory(); |
| 986 | } |
| 987 | |
| 988 | function openEmbeddedTool(toolKey) { |
no test coverage detected