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); ImageList.GetIcon(0, Icon); 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?