Autor Beitrag
DrRzf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mo 31.12.07 02:24 
Ich programmiere gerade an einem Editor, in dem man bestimmte Daten für ein produkt angeben muss.
Darunter wird auch ein Bild zur ansicht aufgenommen.
Hier erstmal die procedure für die Bildauswahl.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
procedure TEditor.BtnOpenPictureClick(Sender: TObject);
var
  Pic : TPicture;
  Bmp : TBitmap;
  str : string;
begin
  Pic := TPicture.Create;
  Bmp := TBitmap.Create;
  try
    if EDOpenPictureDlg.Execute then  
      begin
      Pic.LoadFromFile(EDOpenPictureDlg.FileName);    //Bild laden
      if (Pic.Width = 50) and (Pic.Height = 50) then  //Bildgrösse abfragen
        begin
        Bmp.Assign(Pic.Graphic);       //in bitmap wandeln
        Image1.Picture.Bitmap := Bmp;  //bild anzeigen
        IL.Add(Bmp,nil);               //in bildliste einfügen
        EDLblBildFn.Caption := ExtractFileName(EDOpenPictureDlg.FileName); //namen anzeigen
        end
      else  //bild entspricht nicht der grösse die gebraucht wird
        begin
        MessageDlg( 'Bitte Bildformat beachten'#10#13'Bildgrösse = 50x50 Pixel'
            ,mtInformation,[mbOK],0);  //hinweis auf bildgrösse ausgeben
        Image1.Picture.Bitmap := nil;  //bildanzeige im editor löschen
        EDLblBildFn.Caption := '';     //bildnamen löschen
        end;
      end;
  finally
    Pic.Free;
    Bmp.Free;
  end;
end;


Nun zu meiner Frage:
Image1 stellt das Bild in diesem Editor dar. Bei einer falschen Bildauswahl wird dann ein Hinweisfenster angezeigt,
der auf die benötigte Bildgrösse hinweist. danach wird das Image (von voriger anzeigen) gelöscht.
Ich lösche hier das Bild mit
ausblenden Delphi-Quelltext
1:
Image1.Picture.Bitmap := nil;					

Ist diese vorgehensweise problemlos ? Oder wäre besser das alte Bild einfach mit einem rectangle zu überzeichnen ?
Das Image wird ja nachher für das korrekte Bild wieder benötigt.

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.
.#R4id
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Windows XP Prof.
CodeGear Delphi 2007
BeitragVerfasst: Mo 31.12.07 03:54 
Ich nehme immer Image1.Picture.Bitmap.CleanupInstance;... Wusste mal nicht wie ich das Bild raus bekomm und hab einfach das genommen :lol:

_________________
ausblenden Delphi-Quelltext
1:
if CopyAndPaste not avaible then Developer := Helpless;					
DrRzf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mo 31.12.07 04:32 
user profile icon.#R4id hat folgendes geschrieben:
Ich nehme immer Image1.Picture.Bitmap.CleanupInstance;... Wusste mal nicht wie ich das Bild raus bekomm und hab einfach das genommen :lol:


/dito :zustimm:

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 31.12.07 08:13 
ausblenden Delphi-Quelltext
1:
Image1.Picture.Bitmap := nil;					


ist problemlos. CleanupInstance macht wohl genau das selbe ;-)

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
DrRzf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mo 31.12.07 21:46 
Danke, also dürfte es ja keine gröberen abstürze nach sich ziehn. :lol:

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.