要件の説明に画像を挿入するAPIはありますか?

7 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 9 de En. de 2026 a las 0:00
Respondida: MathWorks Support Team el 9 de En. de 2026 a las 8:34
要件の説明に画像を挿入するAPIはありますか?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 9 de En. de 2026 a las 0:00
要件エディター右側プロパティにあるイメージ取り込みボタンと同等の処理を、直接実行できるAPIは提供されておりません。
ただし、要件の「説明」や「根拠」欄にはリッチテキスト(HTML)を設定できるAPIがございます。画像をBase64形式のData URIとして<img>タグで埋め込むことで、同様の表示を実現することが可能です。
% 1) 要件セットを新規作成(既存を使うなら slreq.load でもOK)
rs = slreq.new('image_in_description.slreqx');
% 2) 要件を1つ追加
req = add(rs, Summary="画像埋め込みのサンプル");
% 3) PNGファイルを取得
pngFile = fullfile(pwd, 'Image1.png');
% 4) 画像バイト列を読み込み → Base64化(MATLAB組み込み)
fid = fopen(pngFile, 'rb');
bytes = fread(fid, '*uint8');
fclose(fid);
b64 = matlab.net.base64encode(bytes);
% 5) data URI を組み立てて <img> を Description にセット
datauri = "data:image/png;base64," + b64;
html = [ ...
"<p>この要件の説明にPNG画像をインラインで埋め込みます:</p>", ...
"<figure>", ...
"<img src=""" + datauri + """ alt=""embedded image"" width=""480"">", ...
"</figure>" ...
];
req.Description = strjoin(html, newline);
% 6) 保存
save(rs);

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!