일부 이미지를 오브젝트 목록에로드 한 다음 리콜하려고합니다. 그러나 그 이미지를 보여주지 않는가?objectlist가 데이터를 검색하지 않습니다.
procedure TForm1.LoadImages(const Dir: string);
var
i: Integer;
CurFileName: string;
JpgIn: TJPEGImage;
BmpOut: TBitmap;
begin
//sets index for object list
CurIdx := -1;
i := 0;
while True do
begin
//gets current folder
CurFileName := Format('%s%d.jpg',
[IncludeTrailingPathDelimiter(Dir), i]);
if not FileExists(CurFileName) then
Break;
//creates jpgin
JpgIn := TJPEGImage.Create;
try
//loads jpgin
JpgIn.LoadFromFile(CurFileName);
//creates TBitmap and sets width to same as jpgs
BmpOut := TBitmap.Create;
bmpout.Width := jpgin.Width;
bmpout.Height := jpgin.Height;
try
BmpOut.Assign(JpgIn);
//if i assign it here it works, showing last image of course
//zimage1.Bitmap.Width := bmpout.Width;
//zimage1.Bitmap.Height := bmpout.Height;
//ZImage1.Bitmap.Assign(bmpout);
//adds 1 to index for object list. thus starting at 0
curIdx := curIdx+1;
//add bitmap to objectlist
CurIdx:= mylist.Add(TBitmap(bmpout));
finally
//free bitmap and jpg
BmpOut.Free;
end;
finally
JpgIn.Free;
end;
Inc(i);
end;
//makes sure cout is above 0
if mylist.Count > 0 then
begin
//create bitmap
BmpOut := TBitmap.Create;
try
//sets width and heigh of bitmap before getting image
bmpout.Height := TBitmap(mylist[curidx]).Height;
bmpout.Width := TBitmap(mylist[curidx]).Width;
bmpout.Assign(TBitmap(mylist[CurIdx]));
//sets zimage width height before getting image.
zimage1.Bitmap.Width := bmpout.Width;
zimage1.Bitmap.Height := bmpout.Height;
ZImage1.Bitmap.Assign(bmpout);
finally
BmpOut.Free;
end;
end;
page:= '0';
end;
내가이 부분을 zimage1에 iamge를로드하는 것이 문제인지 확인하려면이 부분을 확인하십시오.
//zimage1.Bitmap.Width := bmpout.Width;
//zimage1.Bitmap.Height := bmpout.Height;
//ZImage1.Bitmap.Assign(bmpout);
내가 잘못하고 스피 오브젝트리스트와의 뭔가를 생각하는 저를 인도하는 zimage1에 bmpout로드 것을했을 때? 당신은 목록에 항목을 추가 한 다음 즉시 무료 바로 그 동일한 항목
CurIdx:= mylist.Add(TBitmap(bmpout));
finally
//free bitmap and jpg
BmpOut.Free;
end;
:
(mylist.add (TBitmap (bmpout))') 그리고 (bmpout.Free()') 그것을 해제하기 위해 bmpout을 추가하고 있습니다. 'Add'는 객체의 복사본을 생성하지 않습니다. 그래서 당신은 당신의 목록에 잘못된 포인터가 있습니다. – teran
물론 'mylist' 변수가 무엇인지 모르겠습니다 ('추가 '동작에 대해 말하기). 하지만 그것은 TObjectList라고 가정합니다. 'curIdx : = curIdx + 1;'줄은 불필요하다. 그리고 두번째 :'bmpout'을'TBitmap'으로 캐스팅 할 필요가 없습니다. 내가 전화하기 전에 – teran
바닥 근처에, 나는 그것을 다시 만들었습니까? –