Entwickler-Ecke

Multimedia / Grafik - Icons zu Bitmap converter


huhn - Fr 05.11.04 01:49
Titel: Icons zu Bitmap converter
Hi leute
ich wollt ein programm machen das ico in bitmap umwandelt.Ich find aber einfach nicht den fehler!der speichert bei mir immer eine leere seite!ich hoffe ihr könnt mir helfen! :cry:

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:
procedure TForm1.Button1Click(Sender: TObject);
 var 
  s : string;
  Icon: TIcon;
begin
     OpenDialog1.DefaultExt := '.ICO';

  OpenDialog1.Filter := 'icons (*.ico)|*.ICO';
  OpenDialog1.Options := [ofOverwritePrompt, ofFileMustExist, ofHideReadOnly ];
  if OpenDialog1.Execute then
  begin
    Icon := TIcon.Create;
    try
      Icon.Loadfromfile(OpenDialog1.FileName);
      s:= ChangeFileExt(OpenDialog1.FileName,'.BMP');
      Image1.Width := Icon.Width;
      Image1.Height := Icon.Height;
      Image1.Canvas.Draw(112,0,Icon);
      Image1.Picture.SaveToFile(s);
      ShowMessage(OpenDialog1.FileName + ' Saved to ' + s);
    finally
      Icon.Free;
    end;
  end;

MfG Chicken


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Mo 08.11.2004 um 12:59


bms - Fr 05.11.04 01:59


Delphi-Quelltext
1:
Image1.Canvas.Draw(112,0,Icon);                    


in


Delphi-Quelltext
1:
Image1.Canvas.Draw(0,0,Icon);                    


huhn - Fr 05.11.04 12:22

Hey cool danke!
mensch immmer diese kleinigkeiten! :D


huhn - Mo 22.11.04 21:14

Hey leute
ein freund hat mir einen bug gemeldet und ich hab gleich danach geschaut undden fehleer gefunden.
ursprung:

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:
procedure TForm1.Button1Click(Sender: TObject);  
 var   
  s : string;  
  Icon: TIcon;  
begin  
  OpenDialog1.DefaultExt := '.ICO';  
  OpenDialog1.Filter := 'icons (*.ico)|*.ICO';  
  OpenDialog1.Options := [ofOverwritePrompt, ofFileMustExist, ofHideReadOnly ];  
  if OpenDialog1.Execute then  
  begin  
    Icon := TIcon.Create;  
    try  
      Icon.Loadfromfile(OpenDialog1.FileName);  
      s:= ChangeFileExt(OpenDialog1.FileName,'.BMP');  
      Image1.Width := Icon.Width;  
      Image1.Height := Icon.Height;  
      Image1.Canvas.Draw(112,0,Icon);  
      Image1.Picture.SaveToFile(s);  
      ShowMessage(OpenDialog1.FileName + ' Saved to ' + s);  
    finally  
      Icon.Free;  
    end;  
  end;

ich hab dann folgendes geändert

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:
begin
OpenDialog1.DefaultExt := '.BMP';
  OpenDialog1.Filter := 'Bitmap (*.bmp)|*.BMP';
  OpenDialog1.Options := [ofOverwritePrompt, ofFileMustExist, ofHideReadOnly ];
  if openDialog1.execute then
    Bitmap:=Tbitmap.Create;
    begin
      Image1.Picture.LoadFromFile(openDialog1.Filename);
    end;
  Bmp  := TBitmap.Create;
  Icon := TIcon.Create;
  try
    Bmp.Assign(Image1.Picture);
    ImageList := TImageList.CreateSize(Bmp.Width, Bmp.Height);
    try
      ImageList.AddMasked(Bmp, Bmp.TransparentColor);{hier is mein prob! bmp.transparentcolor}
      ImageList.GetIcon(0, Icon);
      // Save it to a file
      s:= ChangeFileExt(OpenDialog1.FileName,'.ICO');
      Icon.SaveToFile(s);
    finally
      ImageList.Free;
    end;
  finally
    Bmp.Free;
    Icon.Free;
  end;
  ShowMessage(OpenDialog1.FileName + ' Saved to ' + s);
end;

soweit so gut aber immer wenn ich konveriere kommt ein hässliches icon raus was warscheinlich an dem transparentcolo liegt es,gibt es da noch andere?oder was muss ich machen das der es schön konvertiert?


huhn - Mo 22.11.04 21:18

Sorry leute hab vergessen zu sagen das des des image oder bitmap in icon konvertiert und ich hab leider zu spät gemerkt das das topic eigentlich flasch ist