Einzelnen Beitrag anzeigen

thehed

Registriert seit: 22. Mär 2003
14 Beiträge
 
Delphi 6 Enterprise
 
#1

Memory Leck durch Bitmaps?

  Alt 11. Okt 2003, 21:15
Hallo
Ich hab da ein Programm geschrieben dass einige Bilder zu einem grossen merged
leider hab ich jetzt festgestellt das bei jedem Durchlauf 256Mb ram verschwinden
Das ist in etwa die grösse die das fertige Bild hat.
Findet hier jemand das Leck? Ich such schon Stunden


Delphi-Quellcode:
zwischenBitmap := TBitmap.Create;
  zwischenBitmap.Width := 200 ;
  zwischenBitmap.Height := 200;
  hauptBitmap := tbitmap.create;
  hauptBitmap.Width := texturmenge*200 ;
  hauptBitmap.Height := texturmenge*200;

   Bitmap := TBitmap.Create;

 // overwrite file if it exists
  ilEnable( il_File_Overwrite );
  // -----------------Bilder laden ------------------------------------
  //progresbar steuerung-------
  progressbar1.max:=texturmenge*texturmenge;
  progressbar1.Position:=0;

  for xi:=0 to (texturmenge-1) do
   begin
    for yi:=0 to (texturmenge-1) do
     begin
   MemDC := CreateCompatibleDC(Canvas.Handle);

  ilGenImages(1, @imgID);
  ilBindImage(imgid);

     // Bild Laden
   xwert:=inttostr(xi);
   ywert:=inttostr(yi);
   namen:=('texture\tx0'+(xwert)+'x0'+(ywert)+'.dds');

 ilLoadImage (pchar(namen));
 progressbar1.position:=progressbar1.Position+1;
 Bitmap := TBitmap.Create;
  Bitmap.Width := ilGetInteger(IL_IMAGE_WIDTH);
  Bitmap.Height :=ilGetInteger(IL_IMAGE_HEIGHT);
 _Bitmap := ilutConvertToHBitmap(Bitmap.Canvas.Handle);

  SelectObject(MemDC, _Bitmap);
  //das ist klar

  BitBlt(Bitmap.Canvas.Handle,(0),(0), Bitmap.Width, Bitmap.Height,
    MemDC, 0,0, SRCCOPY);

   zwischenbitmap.canvas.stretchdraw(rect(0,0,200,200),bitmap);

   BitBlt(hauptbitmap.Canvas.Handle,(xi*200),(yi*200), Bitmap.Width, Bitmap.Height,
   zwischenBitmap.Canvas.Handle,0,0, SRCCOPY);

   ilDeleteImages(1, @ImgId);
    DeleteDC(MemDC);
     DeleteObject(_Bitmap);
      bitmap.Free;


  end;
  end;
  iluDeleteImage(imgID);
  ilDeleteImages(1, @ImgId);
   DeleteObject(_Bitmap);
   DeleteDC(MemDC);

  Image1.Picture.Assign(hauptbitmap);

  bitmap:=tbitmap.create;
   try
    bitmap.Width:= image1.Width;
    bitmap.Height:= image1.Height;
    bitmap.Canvas.CopyMode:= cmSrcCopy;
    bitmap.Canvas.CopyRect(
      Rect(0, 0, bitmap.Width, bitmap.Height), image1.Canvas,
      Rect(0, bitmap.Height - 1, bitmap.Width, -1));
    image1.picture.assign(bitmap);
  finally
   Bitmap.Free;
    end;

  hauptbitmap.free;
  zwischenbitmap.Free;
  Mit Zitat antworten Zitat