Autor Beitrag
menticore
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 24

Win XP
D7 Enterprise
BeitragVerfasst: Mi 07.11.07 20:19 
Hallo,

Im Grunde eine etwas ungewöhnliche Frage. Ich benutze den Mozilla Firefox und oben rechts kann man eigene Suchmaschinen einfügen. Dazu erstellt man unter "\Programme\Mozilla Firefox\searchplugins\" eine neue XML datei. Wie man das macht steht unter Developer Mozilla.

Zur Idee:
Nun hatte ich zuerst ein Script geschrieben, was solch eine Datei automatisch erstellt. Mein Problem: Wie binde ich ein Icon mit ein. Man kann unter der Seite URI Kitchen ein Favicon in Data umwandeln, aber ich schaffe es nicht die Daten auszulesen. Klickt man mit dem IE (Version 6, mehrere PCs schon getestet), dann kommt ein "Die Seite kann nicht angezeigt werden" Fehler. Über Firefox gehts. Aber diesen Umweg will ich nicht machen (bin auch am Ende meines Wissens)

Also versuche ich es jetzt über Delphi. Gibt es eine Möglichkeit, ein Favicon (wie das Google Icon (es muss ein link sein)) in ein XML Format alá "data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAA[......]" umzuwandeln? Gibt es dazu eine Funktion? Wenn, ja welche?

Das URI Kitchen hat auch den Quelltext dazu, aber das ist Perl und ich kann damit überhaupt nichts anfangen. (Source)

Wär super, wenn jemand was findet....

Gruß,
manticore
menticore Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 24

Win XP
D7 Enterprise
BeitragVerfasst: So 11.11.07 22:22 
hat keiner eine idee?

schade...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 12.11.07 00:09 
Moin!

Schonmal nach Suche in: Delphi-Forum, Delphi-Library BASE64 gesucht? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
menticore Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 24

Win XP
D7 Enterprise
BeitragVerfasst: Mo 12.11.07 18:14 
hey.

danke für antwort. habe unter allem gesucht, aber bisher kaum was gefunden. das runterladen des Icons funktioniert ohne Probleme. das umwandeln ist das problem.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  DownLoadInternetFile('http://www.google.de/favicon.ico','test.ico');
  stream:=TStream.Create;
  ico:=TIcon.Create;
  ico.LoadFromFile('test.ico');
  ico.SaveToStream(stream);
  memo1.Lines.Add(IdEncoderMIME1.Encode(stream));


ich mache da was falsch, aber was? ich möchte das Icon codiert haben als Mime-Typ, base 64, sodass so etwas herauskommt wie:
www.delphi-forum.de/...highlight=base64+xml

ich verzweifle -.-
menticore Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 24

Win XP
D7 Enterprise
BeitragVerfasst: Di 13.11.07 20:00 
Hi

nach langem Suchen bin ich endlich fündig geworden. Leider nicht hier.
auf DelphiPraxis gibt es eine Base64 Kodierungs Unit. Die runterladen und 2 Funktionen im Programm einfügen, die ich auf einer ähnlichen Seite gefunden habe:

Decodieren:
ausblenden 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:
function Base64DecodeFile(ABase64Str: String; AFileName: String): Boolean;
var
  InSize, OutSize: Cardinal;
  PIn, POut: Pointer;
begin
  result:= False;
  // get size of source
  InSize := Length(ABase64Str);
  // calculate size for destination
  PIn := @ABase64Str[1];
  OutSize := CalcDecodedSize(PIn, InSize);
  // prepare string length to fit result data
  with TMemoryStream.Create() do
  try
    SetSize(OutSize);
    POut := Memory;
    // decode !
    if Base64Decode(PIn, InSize, POut) then
    begin
      SaveToFile(AFileName);
      result:= True;
    end;
  finally
    Free;
  end;
end;


Encodieren:
ausblenden 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:
function Base64EncodeFile(AFileName: Stringvar ABase64Str: String): Boolean;
var
  ms: TMemoryStream;
  InSize, OutSize: Cardinal;
  PIn, POut: Pointer;
begin
  result:= False;
  if FileExists(AFileName) then
  begin
    with TMemoryStream.Create() do
    try
      LoadFromFile(AFileName);
      // get size of source
      InSize := Size;
      Position:= 0;
      // calculate size for destination
      OutSize := CalcEncodedSize(InSize);
      SetLength(ABase64Str, OutSize);
      // encode !
      PIn := Memory;
      POut:= @ABase64Str[1];
      Base64Encode(PIn, InSize, POut);
      result:= True;
    finally
      Free;
    end;
  end;
end;


und damit lässt sich der Spaß anwenden und es funktioniert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
var
  s:string;
begin
  Base64EncodeFile('favicon.ico',s);
  memo1.Lines.Add(s);
end;