Autor Beitrag
hui1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Fr 22.12.06 06:46 
Hallo,

ich hab was tolles herausgefunden, das wahrscheinlich alle haben wollen, wenn das Programm fertig ist ;)
Naja ich muss ein Byte auf zwei Aufspalten. Ich hab mir gedacht, einfach dies zu machen ->
10011110 --- 1001|1110 ---> 1110 -> 00001110
|----------> 1001 -> 00001001
Dadurch hat man jetzt zwei Byte.
Die nur beide einen Wert von 0 bis 15 haben können. Das finde ich schonmal sehr gut ^^

Ich hab das so umgesetzt:
ausblenden volle Höhe 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:
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:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
  function asc(chrs: char): Integer;
  var
    x: Integer;
  begin
    for x := 0 to 255 do begin
      if (chr(x) = chrs) then
        Result := x;
    end;
  end;

var
  y,x,z,zufall: Integer;
  Stream, WriteStream: TFileStream;
  st, dateiname, sabing: string;
  onechr: Array[0..1000000] of char;
  charlist: array[0..255] of string;
begin
  if opendialog1.Execute then begin
    if fileexists(opendialog1.FileName) then begin
      for y := 0 to 255 do begin
        inc(loader[1]);
        if loader[1] = 2 then begin loader[1] := 0; inc(loader[2]); end;
        if loader[2] = 2 then begin loader[2] := 0; inc(loader[3]); end;
        if loader[3] = 2 then begin loader[3] := 0; inc(loader[4]); end;
        if loader[4] = 2 then begin loader[4] := 0; inc(loader[5]); end;
        if loader[5] = 2 then begin loader[5] := 0; inc(loader[6]); end;
        if loader[6] = 2 then begin loader[6] := 0; inc(loader[7]); end;
        if loader[7] = 2 then begin loader[7] := 0; inc(loader[8]); end;
        if loader[8] = 2 then begin loader[8] := 1; end;
        charlist[y] := inttostr(loader[8]) + inttostr(loader[7]) + inttostr(loader[6]) + inttostr(loader[5]) + inttostr(loader[4]) + inttostr(loader[3]) + inttostr(loader[2]) + inttostr(loader[1]);
      end;
      dateiname := opendialog1.FileName;
      WriteStream := TFileStream.Create(SysUtils.GetEnvironmentVariable('temp') + '\' + ExtractFileName(dateiname), fmCreate);
      Stream := TFileStream.Create(dateiname, fmOpenRead);
      try
        for y := 0 to (Stream.Size div 1000000)-1 do begin
          Stream.Read(onechr, 1000000);
          sabing:='';
          For x:=0 to 1000000 do begin
            inc(z);
            if z<=Stream.Size then begin
            st := charlist[asc(onechr[x])];
            sabing := sabing + chr(bitsi(strtoint(st[1] + st[2] + st[3] + st[4]))) + chr(bitsi(strtoint(st[5] + st[6] + st[7] + st[8])));
            end else
              Label1.Caption:='Hier hat er aufgehört!';
          end;
          WriteStream.Write(pchar(sabing)^, length(sabing));
        end;
      end;
    end;
  end;
end;

function TForm1.bitsi(zeile: Integer): Integer;
begin
  if 0 = zeile then Result := 1;
  if 1 = zeile then Result := 2;
  if 10 = zeile then Result := 3;
  if 11 = zeile then Result := 4;
  if 100 = zeile then Result := 5;
  if 101 = zeile then Result := 6;
  if 110 = zeile then Result := 7;
  if 111 = zeile then Result := 8;
  if 1000 = zeile then Result := 9;
  if 1001 = zeile then Result := 10;
  if 1010 = zeile then Result := 11;
  if 1011 = zeile then Result := 12;
  if 1100 = zeile then Result := 13;
  if 1101 = zeile then Result := 14;
  if 1110 = zeile then Result := 15;
  if 1111 = zeile then Result := 16;
  if 10000 = zeile then Result := 17;
  if 10001 = zeile then Result := 18;
  if 10010 = zeile then Result := 19;
  if 10011 = zeile then Result := 20;
  if 10100 = zeile then Result := 21;
  if 10101 = zeile then Result := 22;
  if 10110 = zeile then Result := 23;
  if 10111 = zeile then Result := 24;
  if 11000 = zeile then Result := 25;
  if 11001 = zeile then Result := 26;
  if 11010 = zeile then Result := 27;
  if 11011 = zeile then Result := 28;
  if 11100 = zeile then Result := 29;
  if 11101 = zeile then Result := 30;
  if 11110 = zeile then Result := 31;
  if 11111 = zeile then Result := 32;
  if 100000 = zeile then Result := 33;
  if 100001 = zeile then Result := 34;
  if 100010 = zeile then Result := 35;
  if 100011 = zeile then Result := 36;
  if 100100 = zeile then Result := 37;
  if 100101 = zeile then Result := 38;
  if 100110 = zeile then Result := 39;
  if 100111 = zeile then Result := 40;
  if 101000 = zeile then Result := 41;
  if 101001 = zeile then Result := 42;
  if 101010 = zeile then Result := 43;
  if 101011 = zeile then Result := 44;
  if 101100 = zeile then Result := 45;
  if 101101 = zeile then Result := 46;
  if 101110 = zeile then Result := 47;
  if 101111 = zeile then Result := 48;
  if 110000 = zeile then Result := 49;
  if 110001 = zeile then Result := 50;
  if 110010 = zeile then Result := 51;
  if 110011 = zeile then Result := 52;
  if 110100 = zeile then Result := 53;
  if 110101 = zeile then Result := 54;
  if 110110 = zeile then Result := 55;
  if 110111 = zeile then Result := 56;
  if 111000 = zeile then Result := 57;
  if 111001 = zeile then Result := 58;
  if 111010 = zeile then Result := 59;
  if 111011 = zeile then Result := 60;
  if 111100 = zeile then Result := 61;
  if 111101 = zeile then Result := 62;
  if 111110 = zeile then Result := 63;
  if 111111 = zeile then Result := 64;
  if 1000000 = zeile then Result := 65;
  if 1000001 = zeile then Result := 66;
  if 1000010 = zeile then Result := 67;
  if 1000011 = zeile then Result := 68;
  if 1000100 = zeile then Result := 69;
  if 1000101 = zeile then Result := 70;
  if 1000110 = zeile then Result := 71;
  if 1000111 = zeile then Result := 72;
  if 1001000 = zeile then Result := 73;
  if 1001001 = zeile then Result := 74;
  if 1001010 = zeile then Result := 75;
  if 1001011 = zeile then Result := 76;
  if 1001100 = zeile then Result := 77;
  if 1001101 = zeile then Result := 78;
  if 1001110 = zeile then Result := 79;
  if 1001111 = zeile then Result := 80;
  if 1010000 = zeile then Result := 81;
  if 1010001 = zeile then Result := 82;
  if 1010010 = zeile then Result := 83;
  if 1010011 = zeile then Result := 84;
  if 1010100 = zeile then Result := 85;
  if 1010101 = zeile then Result := 86;
  if 1010110 = zeile then Result := 87;
  if 1010111 = zeile then Result := 88;
  if 1011000 = zeile then Result := 89;
  if 1011001 = zeile then Result := 90;
  if 1011010 = zeile then Result := 91;
  if 1011011 = zeile then Result := 92;
  if 1011100 = zeile then Result := 93;
  if 1011101 = zeile then Result := 94;
  if 1011110 = zeile then Result := 95;
  if 1011111 = zeile then Result := 96;
  if 1100000 = zeile then Result := 97;
  if 1100001 = zeile then Result := 98;
  if 1100010 = zeile then Result := 99;
  if 1100011 = zeile then Result := 100;
  if 1100100 = zeile then Result := 101;
  if 1100101 = zeile then Result := 102;
  if 1100110 = zeile then Result := 103;
  if 1100111 = zeile then Result := 104;
  if 1101000 = zeile then Result := 105;
  if 1101001 = zeile then Result := 106;
  if 1101010 = zeile then Result := 107;
  if 1101011 = zeile then Result := 108;
  if 1101100 = zeile then Result := 109;
  if 1101101 = zeile then Result := 110;
  if 1101110 = zeile then Result := 111;
  if 1101111 = zeile then Result := 112;
  if 1110000 = zeile then Result := 113;
  if 1110001 = zeile then Result := 114;
  if 1110010 = zeile then Result := 115;
  if 1110011 = zeile then Result := 116;
  if 1110100 = zeile then Result := 117;
  if 1110101 = zeile then Result := 118;
  if 1110110 = zeile then Result := 119;
  if 1110111 = zeile then Result := 120;
  if 1111000 = zeile then Result := 121;
  if 1111001 = zeile then Result := 122;
  if 1111010 = zeile then Result := 123;
  if 1111011 = zeile then Result := 124;
  if 1111100 = zeile then Result := 125;
  if 1111101 = zeile then Result := 126;
  if 1111110 = zeile then Result := 127;
  if 1111111 = zeile then Result := 128;
  if 10000000 = zeile then Result := 129;
  if 10000001 = zeile then Result := 130;
  if 10000010 = zeile then Result := 131;
  if 10000011 = zeile then Result := 132;
  if 10000100 = zeile then Result := 133;
  if 10000101 = zeile then Result := 134;
  if 10000110 = zeile then Result := 135;
  if 10000111 = zeile then Result := 136;
  if 10001000 = zeile then Result := 137;
  if 10001001 = zeile then Result := 138;
  if 10001010 = zeile then Result := 139;
  if 10001011 = zeile then Result := 140;
  if 10001100 = zeile then Result := 141;
  if 10001101 = zeile then Result := 142;
  if 10001110 = zeile then Result := 143;
  if 10001111 = zeile then Result := 144;
  if 10010000 = zeile then Result := 145;
  if 10010001 = zeile then Result := 146;
  if 10010010 = zeile then Result := 147;
  if 10010011 = zeile then Result := 148;
  if 10010100 = zeile then Result := 149;
  if 10010101 = zeile then Result := 150;
  if 10010110 = zeile then Result := 151;
  if 10010111 = zeile then Result := 152;
  if 10011000 = zeile then Result := 153;
  if 10011001 = zeile then Result := 154;
  if 10011010 = zeile then Result := 155;
  if 10011011 = zeile then Result := 156;
  if 10011100 = zeile then Result := 157;
  if 10011101 = zeile then Result := 158;
  if 10011110 = zeile then Result := 159;
  if 10011111 = zeile then Result := 160;
  if 10100000 = zeile then Result := 161;
  if 10100001 = zeile then Result := 162;
  if 10100010 = zeile then Result := 163;
  if 10100011 = zeile then Result := 164;
  if 10100100 = zeile then Result := 165;
  if 10100101 = zeile then Result := 166;
  if 10100110 = zeile then Result := 167;
  if 10100111 = zeile then Result := 168;
  if 10101000 = zeile then Result := 169;
  if 10101001 = zeile then Result := 170;
  if 10101010 = zeile then Result := 171;
  if 10101011 = zeile then Result := 172;
  if 10101100 = zeile then Result := 173;
  if 10101101 = zeile then Result := 174;
  if 10101110 = zeile then Result := 175;
  if 10101111 = zeile then Result := 176;
  if 10110000 = zeile then Result := 177;
  if 10110001 = zeile then Result := 178;
  if 10110010 = zeile then Result := 179;
  if 10110011 = zeile then Result := 180;
  if 10110100 = zeile then Result := 181;
  if 10110101 = zeile then Result := 182;
  if 10110110 = zeile then Result := 183;
  if 10110111 = zeile then Result := 184;
  if 10111000 = zeile then Result := 185;
  if 10111001 = zeile then Result := 186;
  if 10111010 = zeile then Result := 187;
  if 10111011 = zeile then Result := 188;
  if 10111100 = zeile then Result := 189;
  if 10111101 = zeile then Result := 190;
  if 10111110 = zeile then Result := 191;
  if 10111111 = zeile then Result := 192;
  if 11000000 = zeile then Result := 193;
  if 11000001 = zeile then Result := 194;
  if 11000010 = zeile then Result := 195;
  if 11000011 = zeile then Result := 196;
  if 11000100 = zeile then Result := 197;
  if 11000101 = zeile then Result := 198;
  if 11000110 = zeile then Result := 199;
  if 11000111 = zeile then Result := 200;
  if 11001000 = zeile then Result := 201;
  if 11001001 = zeile then Result := 202;
  if 11001010 = zeile then Result := 203;
  if 11001011 = zeile then Result := 204;
  if 11001100 = zeile then Result := 205;
  if 11001101 = zeile then Result := 206;
  if 11001110 = zeile then Result := 207;
  if 11001111 = zeile then Result := 208;
  if 11010000 = zeile then Result := 209;
  if 11010001 = zeile then Result := 210;
  if 11010010 = zeile then Result := 211;
  if 11010011 = zeile then Result := 212;
  if 11010100 = zeile then Result := 213;
  if 11010101 = zeile then Result := 214;
  if 11010110 = zeile then Result := 215;
  if 11010111 = zeile then Result := 216;
  if 11011000 = zeile then Result := 217;
  if 11011001 = zeile then Result := 218;
  if 11011010 = zeile then Result := 219;
  if 11011011 = zeile then Result := 220;
  if 11011100 = zeile then Result := 221;
  if 11011101 = zeile then Result := 222;
  if 11011110 = zeile then Result := 223;
  if 11011111 = zeile then Result := 224;
  if 11100000 = zeile then Result := 225;
  if 11100001 = zeile then Result := 226;
  if 11100010 = zeile then Result := 227;
  if 11100011 = zeile then Result := 228;
  if 11100100 = zeile then Result := 229;
  if 11100101 = zeile then Result := 230;
  if 11100110 = zeile then Result := 231;
  if 11100111 = zeile then Result := 232;
  if 11101000 = zeile then Result := 233;
  if 11101001 = zeile then Result := 234;
  if 11101010 = zeile then Result := 235;
  if 11101011 = zeile then Result := 236;
  if 11101100 = zeile then Result := 237;
  if 11101101 = zeile then Result := 238;
  if 11101110 = zeile then Result := 239;
  if 11101111 = zeile then Result := 240;
  if 11110000 = zeile then Result := 241;
  if 11110001 = zeile then Result := 242;
  if 11110010 = zeile then Result := 243;
  if 11110011 = zeile then Result := 244;
  if 11110100 = zeile then Result := 245;
  if 11110101 = zeile then Result := 246;
  if 11110110 = zeile then Result := 247;
  if 11110111 = zeile then Result := 248;
  if 11111000 = zeile then Result := 249;
  if 11111001 = zeile then Result := 250;
  if 11111010 = zeile then Result := 251;
  if 11111011 = zeile then Result := 252;
  if 11111100 = zeile then Result := 253;
  if 11111101 = zeile then Result := 254;
  if 11111110 = zeile then Result := 255;
  if 11111111 = zeile then Result := 256;
  Result := Result - 1;
end;


Dieser COde Splittet es auf. Bin mir aber bei dem COde nicht sicher, ob er auch wirklich jedes einzelne Byte teilt.
Kann mir jemand die Obere Procedure davon ein wenig korririeren oder sagen was falsch ist. Es sollen ja alles Bytes geteilt werden. Wie bekomme ich das hin, dass das Programm schneller läuft, auf meinem Rechner läuft es auf 80KB/s das sehr langsam ist. Da ich dieses Programm bei Großen Dateien einsetzen muss. Die ca. 700MB sind.

Wäre schön, wenn ich tipps bekomme. Ist echt wichtig ;) Und sehr nützlich wenn es schnell ist :)
Krieg ich die Geschwindigkeit irgendwie auf 1MB/s oder 10MB/s hoch????

MfG
hui1991
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Fr 22.12.06 06:53 
sorry, aber ich sehe bei deinen Quellen nicht durch!
Ein Byte in Lo (untere Tetrade) und Hi(obere Tetrade) aufteilen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure SplitByte (const A: Byte; var lowA,HighA: Byte);
begin
  LowA := A and $0F;
  HighA := (A and $F0) shr 4;
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!


Zuletzt bearbeitet von Kroko am Fr 22.12.06 09:24, insgesamt 1-mal bearbeitet
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 22.12.06 07:53 
Um die oberen vier Bits zu erhalten teilst du die Zahl einfach durch 16 und lässt den Rest der Division weg. Im Binärsystem wird die Zahl nämlich eins nach rechts verschoben, wenn du durch zwei teilst. Um die unteren vier Bits zu erhalten nimmst du den Rest der Division durch 16.

Wieso das geht kann ich dir mal im 10-er System veranschaulichen. Sagen wir mal wir hätten die Dezimalzahl "3149" und wir möchten die ersten zwei Ziffern und die letzten zwei Ziffern voneinander trennen (d.h. in "31" und "49" aufteilen). Um bei der Zahl 3149 die 31 rauszubekommen würdest du durch 100 teilen und den Rest weglassen. Die 49 ist dann genau der Rest der Division:
3149/100 = 31 Rest 49

Wie gesagt im Dualsystem teilt man durch 2, bei 4 Bits durch 2^4=16. Das ganze kann man programmiertechnisch etwas optimieren:
Hi4 := MyByte shr 4;
Lo4 := MyByte and $f;
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Fr 22.12.06 08:26 
Hallo,

da ist aber einiges merkwürdig.
Deine Funktion asc(aus Basic?) heißt in Delphi einfach ord.
Du erzeugst erst für alle Bytewerte (0..255)die resultierenden Strings in Binaärschreibweise (00000000..11111111)
st := charlist[asc(onechr[x])]; <-- st ist jetzt aus (00000000..11111111)
jetzt wandelst Du st in zwei Zeichen mit je chr(0..15) das ist nichts hexadezimales, was Du wohl dachtest.
sabing := sabing + chr(bitsi(strtoint(st[1] + st[2] + st[3] + st[4]))) + chr(bitsi(strtoint(st[5] + st[6] + st[7] + st[8])));
Für Hexadezimale Darstellung reicht :
ausblenden volle Höhe 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:
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, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var
  y,x,z,zufall: Integer;
  Stream, WriteStream: TFileStream;
  st, dateiname, sabing: string;
  onechr: Array[0..1000000-1] of byte;
  charlist: array[0..255] of string;
begin
  if opendialog1.Execute then
    begin
    if fileexists(opendialog1.FileName) then
      begin
      dateiname := opendialog1.FileName;
      try
        WriteStream := TFileStream.Create(SysUtils.GetEnvironmentVariable('temp') + '\' + ExtractFileName(dateiname), fmCreate);
        Stream := TFileStream.Create(dateiname, fmOpenRead);
        z :=Stream.Size;
        memo1.Lines.add(Format('Anzahl %d',[z]));
        for y := 0 to (Stream.Size div 1000000) do
          begin
          Stream.Read(onechr, 1000000);
          sabing:='';
          For x:=0 to 1000000-1 do
            begin
            dec(z); //hier z einfach rückwärts gezählt;
            if z>0 then
              sabing := sabing + Format('%.2x',[oneChr[x]])
            else
              begin
              Button1.Caption:='Hier hat er aufgehört!';
              break;
              end;
            end;
          //memo1.Lines.Add(sabing);
          WriteStream.Write(pchar(sabing)^, length(sabing));
          end;
      finally
        WriteStream.free;
        Stream.free;

      end;
    end;
  end;
end;

end.


Gruß Horst
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Fr 22.12.06 15:26 
Hi,

ihr hattet mich falsch verstanden, wie im Code zu sehen wurden Binär gesplittet.
4 Bit links und 4 Bit recht. Vor beiden ist immer 0000 dann wird es zu zwei Bytes.
Das Ziel ist es. Das nur 0.15 Zeichenkombinationen gibt.
Das muss so sein. Weil sonst bringt es mir nix.
Also wie schaffe ich es das es schnell umberechnet wird?
Ich hab es ja schonmal programmiert.
hm.. das Problem war die zeit. :(
Mal sehen ob ich was finde, was besser ist.

MfG
hui1991
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Fr 22.12.06 15:44 
Hallo,

dann nimm die Funktion von Kroko und fertig;

ausblenden volle Höhe 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:
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:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
unit Unit1; 


interface 


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

const
  charlist :array [0..15] of string =
             ('00000000','00000001','00000010','00000011','00000100','00000101','00000110','00000111'
             ('00001000','00001001','00001010','00001011','00001100','00001101','00001110','00001111');

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


var 
  Form1: TForm1; 


implementation 


{$R *.dfm} 

procedure SplitByte (const A: Byte; var lowA,HighA: Byte); 
begin 
  LowA := A and $0F; 
  HighA := (A and $F0) shr 4; 
end;

procedure TForm1.Button1Click(Sender: TObject); 


var 
  LowA,HighA: byte;

  y,x,z,zufall: Integer; 
  Stream, WriteStream: TFileStream; 
  st, dateiname, sabing: string; 
  onechr: Array[0..1000000-1] of byte; //Byte hier
  charlist: array[0..255] of string; 
begin 
  if opendialog1.Execute then 
    begin 
    if fileexists(opendialog1.FileName) then 
      begin 
      dateiname := opendialog1.FileName; 
      try 
        WriteStream := TFileStream.Create(SysUtils.GetEnvironmentVariable('temp') + '\' + ExtractFileName(dateiname), fmCreate); 
        Stream := TFileStream.Create(dateiname, fmOpenRead); 
        z :=Stream.Size; 
        memo1.Lines.add(Format('Anzahl %d',[z])); 
        for y := 0 to (Stream.Size div 1000000) do 
          begin 
          Stream.Read(onechr, 1000000); 
          sabing:=''; 
          For x:=0 to 1000000-1 do 
            begin 
            dec(z); //hier z einfach rückwärts gezählt; 
            if z>0 then 
              begin
              SplitByte (oneChr[x],lowA,HighA);
              sabing := sabing + chr(HighA)+chr(LowA);
              end 
            else 
              begin 
              Button1.Caption:='Hier hat er aufgehört!'; 
              break; 
              end; 
            end; 
          //memo1.Lines.Add(sabing); 
          WriteStream.Write(pchar(sabing)^, length(sabing)); 
          end; 
      finally 
        WriteStream.free; 
        Stream.free; 


      end; 
    end; 
  end; 
end; 


end.


Gruß Horst
P.S. Geändert.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Fr 22.12.06 16:30 
user profile iconhui1991 hat folgendes geschrieben:
[...] ich hab was tolles herausgefunden, das wahrscheinlich alle haben wollen, wenn das Programm fertig ist ;)[...]


Erwartet uns ein neuer, bahnbrechender Kompressionsalgorithmus? :mrgreen:
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Fr 22.12.06 19:40 
Ach ne, etz geht es net, evtl. war ein Fehler im Code, der hat die Datei gut gemacht. Etz ist sie müll :(
Ich frage mich was da anders war.
hm.. Weil den Code den ich geschickt habe, war nur die Hälfte, etz kann ich es denke ich vergessen.
Wenn die Kompression net hinhaut... *nochwas ausprobier* ^^
Ich frage mich warum, am Anfang 1,5MB auf 2KB runter gingen?
Ich denke das war ein Fehler...

MfG
hui1991
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 22.12.06 19:53 
Verstehe den Sinn eh nicht. Wenn ich aus einem Byte zwei Byte mache, wird die Datei alles andere als kleiner ;-).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Fr 22.12.06 19:58 
Also ich hab gedacht, dadurch das nur 16 Möglichkeiten da sind. Kann eine Datei kleiner werden, als wenn sie 256 Möglichkeiten hat. Aber dies hat das Programm nur gesagt, da ein Fehler drin war. Der nur gleiche Bytes rein getan hat. Deshalb hatte ich das verwendet. Aber komischerweise. Konnte ich es draus wieder die datei bekommen. Frage mich blos wie ich das geschafft habe. :?: Hm.. aber jetzt funktioniert es nicht. Ich denke das war nur ein kleiner Programmier fehler.
Und deshalb war es so klein. Hm.. weil das wäre sehr heftig wenn durch den Umweg die Dateien 1000 bis 5000-mal kleiner sind.

Danke für eure hilfe. Leider war es umsonst.

MfG
hui1991