Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Bittmaps in Array of TBitmap schreiben (https://www.delphipraxis.net/52694-bittmaps-array-tbitmap-schreiben.html)

Evian 1. Sep 2005 22:07


Bittmaps in Array of TBitmap schreiben
 
Hallöschen,

ich versuche ein paar Bitmaps verkleinert in ein Array of Bitmap zu schreiben.

Delphi-Quellcode:
...
Type
Athumps = Array of Tbitmap;

var
  thumps : Athumps;

...

procedure TForm5.makeminimap;
VAR
a,b,i,he,wi,x,y : INTEGER;
Bild :TBitmap;
jpeg: TJpegImage;
begin
  he := 1000 DIV unit1.YLENTH;
  wi := 1000 DIV unit1.XLENTH;

  setlength(thumps,0);
  setlength(thumps,form1.ListBox2.Count);

  Bild := TBitmap.Create;
  jpeg := TJpegImage.Create;

  Bild.Width := wi; Bild.Height := he;

for i := 1 TO form1.ListBox2.Count do
BEGIN
    Jpeg.Assign(form2.getPicture(i));
    Bild.Canvas.StretchDraw(Rect(0, 0, wi, he),Jpeg);
    thumps[i] := Tbitmap.Create;
    thumps[i].Assign(Bild);
END;

END;
Aber ich bekomme immer eine Invalid - Pointer Exception...

Was mache ich Falsch?!


gruß

Evian

Luckie 1. Sep 2005 22:10

Re: Bittmaps in Array of TBitmap schreiben
 
Delphi-Quellcode:
for i := 1 TO form1.ListBox2.Count do
Muss heißen:
Delphi-Quellcode:
for i := 0 TO form1.ListBox2.Count-1 do

Pseudemys Nelsoni 1. Sep 2005 22:16

Re: Bittmaps in Array of TBitmap schreiben
 
Wo gibst du "JPeg" eigentlich wieder frei?

N Kleiner Tipp noch(Nicht böse nehmen :thumb: ): Bei Google suchenDelphi Styleguide

Evian 1. Sep 2005 22:19

Re: Bittmaps in Array of TBitmap schreiben
 
mh.. :roll: diese doofen Felder, warum müssen die auch immer bei 0 anfangen ?!

ohh Gott, wenn das mein Alter Informatik Lehrer sehen würde...

Zitat:

Zitat von Pseudemys Nelsoni
Wo gibst du "JPeg" eigentlich wieder frei?

N Kleiner Tipp noch(Nicht böse nehmen :thumb: ): Bei Google suchenDelphi Styleguide

naja war nicht der ganze Code ... drunter kommt noch mehr, und dann gebe ich das Bitmap und ddas JPEG wieder frei :)

Pseudemys Nelsoni 1. Sep 2005 22:22

Re: Bittmaps in Array of TBitmap schreiben
 
Ich sehe 2 begins und 2 ends ;) demnach sollte das Jpeg schon dort freigegeben(Try/Finally) sein.

Aber ich kann mich natürlich auch irren ;)

MfG

Evian 1. Sep 2005 22:31

Re: Bittmaps in Array of TBitmap schreiben
 
ja hatte den Code rauscopiert und dann einfach nen End hinten rangeschrieben ... damitt keiner sagt .. "ey da fehlt ja ein End" .. :D

Pseudemys Nelsoni 1. Sep 2005 22:33

Re: Bittmaps in Array of TBitmap schreiben
 
Jetzt hattest du jemand der Dir sagt das ein Objekt nicht freigegen wird. - Viel schlimmer. Ich hoffe du hast daraus gelernt! :warn: :mrgreen: :mrgreen: :mrgreen:


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:17 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz