Autor Beitrag
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Mo 19.08.02 12:26 
Hallo
Wenn ich unter Windows ein BitMap mit dem Editor öffnen bekomme ich den Inhalt in einem Textformat angezeigt.
Ich habe das jetzt auch mal mit einem Memo unter Delphi (4) versucht.
ausblenden Quelltext
1:
memo1.lines.loadfromfile('Bild.bmp');					

Leider passiert dann nicht das selbe wie im Editor sondern es werden nur 4 Zeichen angezeigt
Zitat:

BM®X

Wie bekomme ich es hin, das es aussieht wie im Editor :?:
cu Patmann
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Mo 19.08.02 15:16 
Hallo patmann2001,

ich habe es nicht ausprobiert, aber ich würde das Bild als HEX-Code einlesen und diesen dann im Memo ausgeben.

_________

Ex0rzist
MathiasH
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 699

WinXP, Win98SE, Debian, Win95
D5 Stand, D6 Prof
BeitragVerfasst: Mo 19.08.02 20:10 
@exorzist: wie wärs, wenn du ihm auch noch sagst, wie das gehen soll, da kann ich ihm leider auch nicht weiterhelfen, aber mit den Standard "Borland-Hausmitteln"(VCL) wirds wohl nicht mit einer Zeile QT möglich sein

MathiasH

_________________
"Viel von sich reden, kann auch ein Mittel sein, sich zu verbergen."
Friedrich Nietzsche
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Mo 19.08.02 20:42 
@MathiasH:
Na gut, dann poste ich hier mal die entsprechende Unit.
Man benötigt:
1x TMemo
1x TButton
2x TLabel
1x TOpenDialog

Was macht das Programm? Es liest eine beliebige Datei ein und gibt den HEX-Code im Memo aus.
Es ist aber sehr langsam. Bitte nicht unbedingt mit Dateien >100kB testen.
Naja, es ist ja auch nur ein Grundgerüst.

Hier der Code:
ausblenden volle Höhe 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:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen}
  public
    { Public-Deklarationen}
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

type s2=string[2];

function HexToInt(s:S2):Integer;
begin
s:='0'+s;
result:=strtoint('$'+s);
end;

procedure TForm1.Button1Click(Sender: TObject);
var  f : file;
  buf : array[0..4096]of byte;
  k : string;
  acRead, i: integer;
begin
{$i-}
if opendialog1.execute then
begin
  Memo1.Clear;
  cursor:=crhourglass;
  AssignFile(f,opendialog1.filename);
  Reset(f,1);  if(IoResult = 0) then
  begin
     repeat
       BlockRead(f, buf, sizeof(buf), acRead);
       if(acRead > 0) then
       for i := 0 to acRead do
       begin
       K := IntToHex(buf[i],2);
       Memo1.Text := Memo1.Text+K;
       Application.ProcessMessages;
       end;
       until(acRead = 0);
       Label2.Caption := IntToStr(FileSize(f))+' Bytes';
       Form1.Caption := IntToStr(acReaD);
       CloseFile(f);
       label1.caption:=opendialog1.filename;
       cursor:=crDefault;
       end;
end;
{$I+}
end;


end.


___________

Ex0rzist
patmann2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Mi 21.08.02 09:28 
Danke
Werde das mal ausprobieren.