MCPcopy Index your code
hub / github.com/cifertech/DisplayKit / importRgb565ImageToDisplayKit

Function importRgb565ImageToDisplayKit

app.js:931–986  ·  view source on GitHub ↗
({ symbol, w, h, rgb565 })

Source from the content-addressed store, hash-verified

929}
930
931function 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
988function openEmbeddedTool(toolKey) {

Callers 1

app.jsFile · 0.85

Calls 11

makeIdFunction · 0.85
rgb565ToDataUrlFunction · 0.85
ensureAssetsDefaultsFunction · 0.85
getCurrentDriverModeFunction · 0.85
syncActiveScreenElementsFunction · 0.85
updatePreviewSizeFunction · 0.85
renderElementsFunction · 0.85
updatePropsInputsFunction · 0.85
updateCodeFunction · 0.85
renderAssetsFunction · 0.85
pushHistoryFunction · 0.85

Tested by

no test coverage detected