0

首先,我正在使用以下记录:

type
  TCarouselPhotos = record
    cpDescription:  String;
    cpDurationSec:  Integer;
    cpPhotograph:   TJPEGImage;
    cpOrder:     Integer;
  end;

此记录用于以下数组:

CarouselPhotoArray: array of TCarouselPhotos;

现在我正在尝试将数据库中的数据加载到这个数组中:

CarouselPhotoArray[0].cpPhotograph:= getImageFromBlob;

这是我正在使用的功能:

function TFormMain.getImageFromBlob: TJPEGImage;
var tmpStream: TMemoryStream;
    tmpJPEG: TJPEGImage;
begin
  tmpStream := TMemoryStream.Create;
  tmpJPEG   := TJPEGImage.Create;
  try
    TBlobField(QueryTemp.FieldByName('Afbeelding')).SaveToStream(tmpStream);
    tmpStream.Position := 0;
    tmpJPEG.LoadFromStream(tmpStream);
    If tmpStream.Size > 0
      then Result := tmpJPEG  // note: when I try "image1.picture.graphic := tmpJPEG" it works!
      else Result := nil;
  finally
    tmpStream.Free;
    tmpJPEG.Free;
  end;
end;

不知何故,我没有收到任何错误,但是一旦我尝试显示图片,它就会引发访问冲突错误...

Image1.Picture.Graphic := CarouselPhotoArray[0].cpPhotograph;

这里有什么问题?请帮忙。

4

0 回答 0