Memory Stream を使用して Base64 文字列を画像に変換する非常に古いコードのバグを修正する必要があります。基本的に、base64 文字列として保存された画像のリストをループし、それらを画像に変換してから、ActiveReports を使用して描画します。
バグは、1 つの画像をロードすると、後続のすべての画像が最初の画像のコピーになることです。
文字列から画像への変換を行っているコードを見つけたところ、メモリ ストリームを破棄していないことがすぐにわかりました。using ブロックでメモリ ストリームをラップすると、GDI 例外が発生します。これは、画像がまだ実際にメモリから読み取られていないためだと思いますが、誰かが推測できるかどうかを知りたいです。前もって感謝します!
byte[] oGraphic = null;
try
{
oGraphic = Convert.FromBase64String(psGraphic);
DataDynamics.ActiveReports.Picture oImg = new Picture();
oImg.Top = this.Legend.Top + this.fTopFirst;
oImg.Visible = true;
oImg.Name = sLabelName;
oImg.PictureAlignment = PictureAlignment.Center;
oImg.Image = null;
if (oGraphic != null)
{
var oStream = new MemoryStream(oGraphic);
oImg.Image = System.Drawing.Image.FromStream(oStream);
oImg.Height = Convert.ToSingle(oImg.Image.Height)/(oImg.Image.VerticalResolution);
oImg.Width = Convert.ToSingle(oImg.Image.Width)/(oImg.Image.HorizontalResolution);
oImg.SizeMode = SizeModes.Zoom;
this.fGraphicHeight = oImg.Height;
this.fGraphicWidth = oImg.Width;
if (this.fConstantGraphic > this.fGraphicWidth)
oImg.Left = this.Legend.Left + this.fLeftFirst +
((this.fConstantGraphic - this.fGraphicWidth)/2);
else
oImg.Left = this.Legend.Left + this.fLeftFirst;
}
else
{
this.fGraphicHeight = 0f;
this.fGraphicWidth = 0f;
}
this.GHMap.Controls.Add(oImg);
}
catch (Exception oE)
{
.....
}