Autor Beitrag
Doc Morelli
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Do 21.10.04 20:14 
Hi @ll,

also, ich benutze folgenden Code, um ein Icon zu speichern:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Function GetIconFromFile(FileName: String; Index: Integer): Ticon;
Begin
Result := TIcon.Create;
Result.Handle := ExtractIcon(HInstance, PCHAR(FileName), Index);
End;

procedure TForm1.Button1Click(Sender: TObject);
var Icon : TIcon;
begin
  Icon := TIcon.Create;
  Icon := (GetIconFromFile('C:\Windows\explorer.exe', 0));
  Icon.SaveToFile('C:\icon.ico');
  Icon.Free;
end;


Nur das Problem ist jetzt, dass beim Speichern ein enormer Farbverlust auftritt. Gibt es eine Möglichkeit, diesen zu beheben? Wenn ja, welchen?

MFG Doc
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 21.10.04 21:09 
Dies ist ein Fehler der VCL. Wenn du ein Icon ohne Farbverlust speichern willst, musst du dich selbst um die Speicherung kümmern.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 21.10.04 21:12 
Das ist glaube ich das selbe wie bei dem mitgelieferten Imageeditor:
Der speichert auch nur Icons mit 256 Farben :(
Wie soll man sich denn selber um die Speicherung kümmern?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 21.10.04 21:26 
Icon auf ein Canvas zeichnen und dann von dort Pixel für Pixel in eine ICO-Datei schreiben.
Format-Spezi gibt's bei Wotsit.org :D

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 21.10.04 21:30 
Wie soll ich denn Pixel für Pixel schreiben?
Da muss ich ja die Bytes selber reinschreiben :roll:
Vielleicht verstehen wir uns auch nur falsch...
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 21.10.04 22:22 

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 21.10.04 22:22 
Nur als Hinweis für alle Beteiligten: www.delphipraxis.net...ic37443,0,asc,0.html

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Fr 22.10.04 10:47 
Diese Doppelposterei müsste verboten werden.
Hilft mir aber trotzdem nicht weiter.
Wie speichere ich denn Pixel für Pixel in eine ico Datei?
Die Farbe der Pixel auszulesen ist ja kein Problem,
aber wie zum teufel schreibe ich sie in die Datei?
Ich kann doch nicht einfach eine Datei öffnen, die Farbwerte
in der Reihenfolge reinhscreiben mit writeln und dann als .ico speichern, oder?
Wäre ja absurd...
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 22.10.04 10:55 
Basti hat folgendes geschrieben:
Diese Doppelposterei müsste verboten werden.
Stimmt, um so peinlicher, daß ich's auch gemacht habe (oder ist es etwa noch peinlicher, daß keiner der Mods das bisher gefunden hat? :gruebel: :mrgreen:)

Das von BenBE vorgeschlagene vollkommen manuelle Speichern bleibt einem unter Windows zum Glück erspart, nur muss man halt anstatt der VCL die API benutzen. Alles run um Icons findet sich hier, die API-Funktionen können alles, was die jeweilige Windows-Version kann (TrueColor-Bitmaps mit Win95 haut also trotzdem nicht hin ;-)). Ist zwar ein wenig komplexer und dauert länger, sich da einzuarbeiten, aber man gelangt zum Ziel ;-)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
MrCoder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65

WinXP, SuSE Linux
D7 Ent
BeitragVerfasst: Fr 22.10.04 11:10 
Hi,

@Doc: Willst du unbedingt deinen eigenen Extractor schreiben? Wenn nicht könnte ich mit meinem IconExtractor dienen. Er extrahiert, ohne Farbverlust! Aber wenn du darauf beharrst, deinen eigenen zu schreiben, kann ich dir doch einen Tipp geben: mein IconExtractor lädt die Icons nicht per Handle (kein LoadIcon/ExtractIcon).

MfG,
MrCoder