IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

TCompressionStream et résultat incompris


Sujet :

Langage Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre Expert

    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2007
    Messages
    3 530
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 530
    Par défaut TCompressionStream et résultat incompris
    Bonjour les gens

    J'ai écris ce petit bout de code pour compresser (enfin je le croyais) une chaîne de caractères.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
    function Compressed2(const ASrc: string): string;
    var
      vDest: TStringStream;
      vComp: TCompressionStream;
    begin
      try
        vDest := TStringStream.Create();
     
        vComp := TCompressionStream.Create(TCompressionLevel.clMax, vDest);
        vComp.Write(@ASrc[1], Length(ASrc) * sizeof(char));
      finally
        FreeAndNil(vComp);
     
        vDest.Seek(0, 0);
        Result := vDest.DataString;
        FreeAndNil(vDest);
      end;
    end;
    Elle fonctionne mais si je passe en entrée le classique "Bonjour le monde" qui fait 16 caractères, ça me renvoie une chaîne compressée de 33 caractères.

    Donc, y'a un truc qui m'échappe mais je ne vois pas quoi :-( (à part que 33 c'est 2 * 16 + 1 mais c'est limité comme remarque )

  2. #2
    Expert confirmé
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    11 159
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 11 159
    Par défaut
    Salut,

    si je génère un fichier test.txt sous XP ne contenant que ta chaîne de 16 caractères puis "Clic droit / 7zip / Ajouter à test.zip" je me retrouve avec un fichier de 166 octets.
    Si je choisis "Ajouter à test.7z" le résultat pèse 134 octets.

    Ça doit être un comportement normal, et tu noteras qu'il n'y a pas une ligne de code dans ma manip.

  3. #3
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 096
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 096
    Par défaut
    La compression ajoute un entête, il y a un seuil où la compression ZLib n'est pas fonctionnelle
    Il y a par exemple un CRC32 pour contrôler l'exactitude de la donnée, probablement aussi la longueur de la donnée d'origine, le niveau de compression, l'algorithme de compression ...


    Si tu veux compresser de petit texte, tu peux par exemple stocker sur 6 bit en partant d'un dictionnaire fixe de 64 valeurs.
    Dès que tu veux avoir un dictionnaire variable, il te faut stocker ce dictionnaire

    Tient, je ne sais plus comment ça marche, c'est super vieux

    EDIT : cela comptait les octets répétés, au final, cela doublait souvent la taille de la donnée
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    // -----------------------------------------------------------------------------
    procedure TFrmTestFichier.BtnCompresserByteOccClick(Sender: TObject);
    type
       TCompresseRec = packed record
          Occurence: Byte;
          DataByte: Char;
       end;
    var
       FichierOri: file;
       FichierPack: file; // of TCompresseRec;
       FileNameIn, FileNameOut: string;
       BlockOri: array[Byte] of Char;
       BlockPack: TCompresseRec;
       FlagInc, FlagLast: Boolean;
       idxBlockOri: Integer;
       AmtTransferred: Integer;
       AmtCompressed: Integer;
       SizeOri: Cardinal;
       BlockOriLen, BlockPackLen: Word;
    begin
       BtnCompresserByteOcc.Enabled := False;
       try
            // Bar de Progression à Zéro
          ProgressBarReel.Position := 0;
          ProgressBarCompresse.Position := 0;
     
          FileNameIn := EdPathFileToPack.Text;
          FileNameOut := ChangeFileExt(FileNameIn, '.spboz');
     
            // Prise en Main du Fichier d'Entrée
          AssignFile(FichierOri, FileNameIn);
            // Ouverture du Fichier d'Entrée
          Reset(FichierOri, 1);
          try
               // Prise en Main du Fichier de Sortie
             AssignFile(FichierPack, FileNameOut);
               // Prêt pour l'écriture dans le Fichier de Sortie
             Rewrite(FichierPack, 1);
             try
                if Eof(FichierOri) then begin
                   Exit;
                end;
     
                  // Bar de Progression de 0 à Fin de Fichier
                ProgressBarReel.Max := (FileSize(FichierOri) - 1) * 2;
                ProgressBarCompresse.Max := ProgressBarReel.Max;
                ProgressBarReel.Position := 0;
                ProgressBarCompresse.Position := 0;
     
                  // Initialisation
                BlockOriLen := SizeOf(BlockOri);
                BlockPackLen := SizeOf(BlockPack);
                SizeOri := FileSize(FichierOri);
                  // ATTENTION : Ecriture de la Taille Original (sur 4 Octects)
                BlockWrite(FichierPack, SizeOri, SizeOf(SizeOri));
     
                  // ATTENTION
                  // Dans le Fichier c'est écrit 0 à 255
                  // ...mais cela se comprend de 1 à 256
     
                  // Lecture jusqu'au bout du Fichier d'Entrée
                while not Eof(FichierOri) do begin
                        // Lecture du Fichier d'Entrée
                   BlockRead(FichierOri, BlockOri, BlockOriLen, AmtTransferred);
                        // Bar de Progession
                   ProgressBarReel.StepBy(AmtTransferred - 1);
                   AmtCompressed := 0;
     
                   FlagLast := False;
                   BlockPack.Occurence := 0; // Attention 0 c'est en fait la 1ère
                   BlockPack.DataByte := BlockOri[Low(BlockOri)];
                        // -1 car indice à partir de 0 ...
                   FlagInc := False;
                        // Premier déjà lu, on part sur le second ... jusqu'au dernier (Len-1)
                   for idxBlockOri := Succ(Low(BlockOri)) to AmtTransferred - 1 do begin
                      FlagInc := (BlockPack.DataByte = BlockOri[idxBlockOri]);
                      if FlagInc then begin
                         Inc(BlockPack.Occurence);
                      end else begin
                               // Ecriture Block
                         BlockWrite(FichierPack, BlockPack, BlockPackLen);
                         BlockPack.Occurence := 0; // 0 ne veut pas dire Zéro mais Un !
                         BlockPack.DataByte := BlockOri[idxBlockOri];
                               // Bar de Progession
                         Inc(AmtCompressed, BlockPackLen);
                               // Si c'est le Dernier, on le conserve pour le prochain tour, ...
                         FlagLast := idxBlockOri = AmtTransferred - 1;
                      end;
                   end;
                   if FlagInc or FlagLast then
                   begin
                      BlockWrite(FichierPack, BlockPack, BlockPackLen);
                           // Bar de Progession
                      Inc(AmtCompressed, BlockPackLen);
                   end;
                   ProgressBarCompresse.StepBy(AmtCompressed);
                end;
     
             finally
                CloseFile(FichierPack);
             end;
          finally
             CloseFile(FichierOri);
          end;
       finally
          BtnCompresserByteOcc.Enabled := True;
       end;
    end;
     
    procedure TFrmTestFichier.BtnDeCompresserByteOccClick(Sender: TObject);
    type
       TCompresseRec = packed record
          Occurence: Byte;
          DataByte: Byte;
       end;
    var
       FichierOri: file;
       FichierPack: file; // of TCompresseRec;
       FileNameIn, FileNameOut: string;
       BlockOri: array[Byte] of Byte;
       BlockPack: TCompresseRec;
       SizeOri, SizeOriCalculated, ProgressBlock: Cardinal;
       BlockPackLen: Byte;
    begin
       BtnDeCompresserByteOcc.Enabled := False;
       try
            // Bar de Progression à Zéro
          ProgressBarReel.Position := 0;
          ProgressBarCompresse.Position := 0;
     
          FileNameIn := ChangeFileExt(EdPathFileToPack.Text, '.spbozd');
          FileNameOut := ChangeFileExt(FileNameIn, '.spboz');
     
            // Prise en Main du Fichier d'Entrée
          AssignFile(FichierOri, FileNameIn);
            // Pret à recréer le Fichier d'Entrée
          Rewrite(FichierOri, 1);
          try
               // Prise en Main du Fichier de Sortie
             AssignFile(FichierPack, FileNameOut);
               // Prêt pour la lectured du Fichier de Sortie
             Reset(FichierPack, 1);
             try
                if Eof(FichierPack) then begin
                   Exit;
                end;
     
                  // ATTENTION : Lecture de la Taille Original (sur 4 Octects)
                if FileSize(FichierPack) >= 4 then
                   BlockRead(FichierPack, SizeOri, SizeOf(SizeOri))
                else
                   Exit;
     
                  // Bar de Progression de 0 à Fin de Fichier
                ProgressBarCompresse.Max := FileSize(FichierPack) div High(Word);
                ProgressBarCompresse.Step := 1;
                ProgressBarCompresse.Position := 0;
                ProgressBarReel.Position := 0;
                ProgressBarReel.Max := SizeOri;
     
                  // Initialisation
                BlockPackLen := SizeOf(BlockPack);
                BlockPack.Occurence := 0;
                BlockPack.DataByte := 0;
                ProgressBlock := 0;
                SizeOriCalculated := 0;
     
                  // Lecture jusqu'au bout du Fichier d'Entrée
                while not Eof(FichierPack) do begin
                        // Lecture du Fichier d'Entrée
                   BlockRead(FichierPack, BlockPack, BlockPackLen);
                        // Bar de Progession
     
                   Inc(ProgressBlock);
                   if ProgressBlock = High(Word) then begin
                      ProgressBarCompresse.StepIt();
                      ProgressBlock := 0;
                   end;
                        // Dans le Fichier c'est de 0 à 255 ... donc occurence de 1 à 256
                        // Remplissage des Bytes consécutifs
                   FillMemory(@BlockOri, BlockPack.Occurence + 1, BlockPack.DataByte);
                   Inc(SizeOriCalculated, BlockPack.Occurence + 1);
                        // Ecriture
                   BlockWrite(FichierOri, BlockOri, BlockPack.Occurence + 1);
     
                        // Bar de Progession
                   if (SizeOriCalculated and $0000FFFF) = High(Word) then begin
                      ProgressBarReel.Position := SizeOriCalculated;
                   end;
                end;
     
                if SizeOriCalculated <> SizeOri then
                   ShowMessageFmt('Tailles Différentes : %d <> %s', [SizeOri, SizeOriCalculated]);
             finally
                CloseFile(FichierPack);
             end;
          finally
             CloseFile(FichierOri);
          end;
       finally
          BtnDeCompresserByteOcc.Enabled := True;
       end;
    end;
    Et mon algo avec dictinonaire, jamais fini
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    procedure TFrmTestFichier.BtnCompresserByteHashClick(Sender: TObject);
    var
       FichierOri: file;
       FichierPack: file; // of TCompresseRec;
       FileNameIn, FileNameOut: string;
       BlockOri: array[Byte] of Char;
       HashChanged, HashCompleted: Boolean;
       BlockHash: array[Byte] of Boolean;
       TableHash: array of Byte;
       BlockPack: array of Byte;
    //   FlagInc, FlagLast: Boolean;
       idxBlockHash, idxHash, LenHash, BitPerHash: Byte;
       idxBlockOri: Integer;
       AmtTransferred: Integer;
       AmtCompressed: Integer;
       SizeOri: Cardinal;
       BlockOriLen, BlockPackLen: Word;
     
       function IndexHash(Value: Byte): Byte;
       begin
          for Result := Low(TableHash) to High(TableHash) do
             if TableHash[Result] = Value then
                Exit;
     
          raise Exception.Create('Oh Merde !');
       end;
    begin
       BtnCompresserByteHash.Enabled := False;
       try
            // Bar de Progression à Zéro
          ProgressBarReel.Position := 0;
          ProgressBarCompresse.Position := 0;
     
          FileNameIn := EdPathFileToPack.Text;
          FileNameOut := ChangeFileExt(FileNameIn, '.spbhz');
     
            // Prise en Main du Fichier d'Entrée
          AssignFile(FichierOri, FileNameIn);
            // Ouverture du Fichier d'Entrée
          Reset(FichierOri, 1);
          try
             if Eof(FichierOri) then begin
                Exit;
             end;
     
               // Initialisation
             BlockOriLen := High(BlockOri) - Low(BlockOri);
     
               // Bar de Progression de 0 à Fin de Fichier
             ProgressBarReel.Max := FileSize(FichierOri);
             ProgressBarReel.Position := 0;
     
     
               // Création de la Hash Binaire
             ZeroMemory(@BlockHash, SizeOf(BlockHash));
             HashCompleted := False;
             while not Eof(FichierOri) and not HashCompleted do begin
                  // Lecture du Fichier d'Entrée
                BlockRead(FichierOri, BlockOri, BlockOriLen, AmtTransferred);
                  // Bar de Progession
                ProgressBarReel.StepBy(AmtTransferred - 1);
     
                HashChanged := False;
                  // Indice de 0 à Len-1 : "Min( BlockOriLen, AmtTransferred ) - 1"
                for idxBlockOri := Low(BlockOri) to AmtTransferred - 1 do begin
                   if not BlockHash[Byte(BlockOri[idxBlockOri])] then begin
                      BlockHash[Byte(BlockOri[idxBlockOri])] := True;
                      HashChanged := True;
                   end;
                end;
     
                if HashChanged then
                begin
                   HashCompleted := True;
                   for idxBlockHash := Low(BlockHash) to High(BlockHash) do begin
                      if not BlockHash[idxBlockHash] then
                      begin
                         HashCompleted := False;
                         Break;
                      end;
                   end;
                end;
             end;
     
               // Remplissage de Table de Hashage
             LenHash := 0;
             for idxBlockHash := Low(BlockHash) to High(BlockHash) do
                if BlockHash[idxBlockHash] then
                   Inc(LenHash);
     
             SetLength(TableHash, LenHash);
             idxHash := 0;
             for idxBlockHash := Low(BlockHash) to High(BlockHash) do begin
                if BlockHash[idxBlockHash] then
                begin
                   TableHash[idxHash] := idxBlockHash;
                   Inc(idxHash);
                end;
             end;
             BitPerHash := Ceil(Log2(LenHash));
             if BitPerHash = 8 then // Inutile, la Table de Hash contient autant d'élement ...
                Exit;
     
               //BlockPackLen := BlockOriLen div Trunc(Log2(256)) * BitPerHash;
             BlockOriLen := 8 * 8;
             BlockPackLen := BitPerHash * 8;
             SetLength(BlockPack, BlockPackLen);
     
               // Retour au Début, et nouvel taille de block de lecture
             Reset(FichierOri, BlockOriLen);
     
               // Prise en Main du Fichier de Sortie
             AssignFile(FichierPack, FileNameOut);
               // Prêt pour l'écriture dans le Fichier de Sortie
             Rewrite(FichierPack, 1);
             try
                if Eof(FichierOri) then begin
                   Exit;
                end;
     
                  // Bar de Progression de 0 à Fin de Fichier
                ProgressBarReel.Max := (FileSize(FichierOri) - 1) * 2;
                ProgressBarCompresse.Max := ProgressBarReel.Max;
                ProgressBarReel.Position := 0;
                ProgressBarCompresse.Position := 0;
     
                  // Initialisation
                SizeOri := FileSize(FichierOri);
                  // ATTENTION : Ecriture de la Taille Original (sur 4 Octects)
                BlockWrite(FichierPack, SizeOri, SizeOf(SizeOri));
     
                  // ATTENTION
                  // Dans le Fichier c'est écrit 0 à 255
                  // ...mais cela se comprend de 1 à 256
     
                  // Lecture jusqu'au bout du Fichier d'Entrée
                while not Eof(FichierOri) do begin
                        // Lecture du Fichier d'Entrée
                   BlockRead(FichierOri, BlockOri, 1, AmtTransferred);
                        // Bar de Progession
                   ProgressBarReel.StepBy(AmtTransferred - 1);
                   AmtCompressed := BlockPackLen;
     
                        // Compression Bit à Bit !
                   for idxBlockOri := Succ(Low(BlockOri)) to AmtTransferred - 1 do begin
                           //BlockOri[idxBlockOri]
     
                      for idxBlockHash := Low(BlockHash) to High(BlockHash) do begin
                               (*
                               idxHash := IndexHash(BlockHash[idxBlockHash]);
     
                               // - un compteur comptant le nombre d'entrés
                               case BitPerHash of
                                  1: begin // Sub Pack Octet (8)
                                    // - un compteur qui compte les Bit (décalage) de 0 à 7
                                    // - 8 Octets en Entrée, 1 Octet en Sortie
                                    // 0 : Bytes[0] := idxHash;                   // 1
                                    // i : Bytes[0] := Bytes[0] or idxHash shl i; // Inc(i, 1)
                                  end;
                                  2: begin // Sub Pack Octet (8)
                                    // - un compteur qui compte les Bit (décalage par 2) de 0, 2, 4, 6
                                    // - 4 Octets en Entrée, 1 Octet en Sortie
                                    // 0 : Bytes[0] := idxHash;                   // 2
                                    // i : Bytes[0] := Bytes[0] or idxHash shl i; // Inc(i, 2)
                                  end;
                                  3: begin // Sub Pack 3 Octets (24)
                                    // - un compteur qui l'octet 0 à 2
                                    // - un compteur qui compte les Bit par Octet
                                    // - 8 Octets en Entrée, 3 Octet en Sortie
                                    // 1 - 0 - 0 : Bytes[0] := idxHash;                   // 3
                                    // 2 - 0 - 3 : Bytes[0] := Bytes[0] or idxHash shl 3; // 3
                                    // 3 - 0 - 6 : Bytes[0] := Bytes[0] or idxHash shl 6; // 2
                                    //             Bytes[1] := idxHash shr 2;             // 1 +
                                    // 4 - 1 - 1 : Bytes[1] := Bytes[1] or idxHash shl 1; // 3
                                    // 5 - 1 - 4 : Bytes[1] := Bytes[1] or idxHash shl 4; // 3
                                    // 6 - 1 - 7 : Bytes[1] := Bytes[1] or idxHash shl 7; // 1
                                    //           : Bytes[2] := idxHash shr 1;             // 2 +
                                    // 7 - 2 - 2 : Bytes[2] := Bytes[2] or idxHash shl 2; // 3
                                    // 8 - 2 - 5 : Bytes[2] := Bytes[2] or idxHash shl 5; // 3
                                    // Terminé                                           // 24
                                  end;
                                  4: begin // Sub Pack Octet (8)
                                    // - un compteur qui compte les Bit (décalage par 4) de 0, 4
                                    // - 2 Octets en Entrée, 1 Octet en Sortie
                                    // 0 : Bytes[0] := idxHash;                   // 2
                                    // i : Bytes[0] := Bytes[0] or idxHash shl i; // Inc(i, 4)
                                  end;
                                  5: begin // Sub Pack 5 Octets (40)
                                    // - un compteur qui l'octet 0 à 4
                                    // - un compteur qui compte les Bit par Octet
                                    // - 8 Octets en Entrée, 5 Octet en Sortie
                                    // 1 - 0 - 0 : Bytes[0] := idxHash;                   // 5
                                    // 2 - 0 - 5 : Bytes[0] := Bytes[0] or idxHash shl 5; // 3
                                    //             Bytes[1] := idxHash shr 3;             // 2 +
                                    // 3 - 1 - 2 : Bytes[1] := Bytes[1] or idxHash shl 2; // 5
                                    // 4 - 1 - 7 : Bytes[1] := Bytes[1] or idxHash shl 7; // 1
                                    //             Bytes[2] := idxHash shr 1;             // 4 +
                                    // 5 - 2 - 4 : Bytes[2] := Bytes[2] or idxHash shl 4; // 4
                                    //             Bytes[3] := idxHash shr 4;             // 1 +
                                    // 6 - 3 - 1 : Bytes[3] := Bytes[3] or idxHash shl 1; // 5
                                    // 7 - 3 - 6 : Bytes[3] := Bytes[3] or idxHash shl 6; // 2
                                    //             Bytes[4] := idxHash shr 2;             // 3 +
                                    // 8 - 4 - 3 : Bytes[4] := Bytes[4] or idxHash shl 3; // 5
                                  end;
                                  6: begin // Sub Pack 3 Octets (24)
                                    // - un compteur qui l'octet 0 à 2
                                    // - un compteur qui compte les Bit par Octet
                                    // - 4 Octets en Entrée, 3 Octet en Sortie
                                    // 1 - 0 - 0 : Bytes[0] := idxHash;                   // 6
                                    // 2 - 0 - 6 : Bytes[0] := Bytes[1] or idxHash shl 6; // 2
                                    //             Bytes[1] := idxHash shr 2;             // 4 +
                                    // 3 - 1 - 4 : Bytes[1] := Bytes[1] or idxHash shl 4; // 4
                                    //             Bytes[2] := idxHash shr 4;             // 2 +
                                    // 4 - 2 - 2 : Bytes[2] := Bytes[2] or idxHash shl 2; // 6
                                  end;
                                  7: begin // Sub Pack 7 Octets (56)
                                    // - un compteur qui l'octet 0 à 6
                                    // - un compteur qui compte les Bit par Octet
                                    // - 8 Octets en Entrée, 7 Octet en Sortie
                                    // 1 - 0 - 0 : Bytes[0] := idxHash;                   // 7
                                    // 2 - 0 - 7 : Bytes[0] := Bytes[0] or idxHash shl 7; // 1
                                    //             Bytes[1] := idxHash shr 1;             // 6 +
                                    // 3 - 1 - 6 : Bytes[1] := Bytes[1] or idxHash shl 6; // 2
                                    //             Bytes[2] := idxHash shr 2;             // 5 +
                                    // 4 - 2 - 5 : Bytes[2] := Bytes[2] or idxHash shl 5; // 3
                                    //             Bytes[3] := idxHash shr 3;             // 4 +
                                    // 5 - 3 - 4 : Bytes[3] := Bytes[3] or idxHash shl 4; // 4
                                    //             Bytes[4] := idxHash shr 4;             // 3 +
                                    // 6 - 4 - 3 : Bytes[4] := Bytes[4] or idxHash shl 3; // 5
                                    //             Bytes[5] := idxHash shr 5;             // 2 +
                                    // 7 - 5 - 2 : Bytes[5] := Bytes[5] or idxHash shl 2; // 6
                                    //             Bytes[6] := idxHash shr 6;             // 1 +
                                    // 8 - 6 - 1 : Bytes[6] := Bytes[5] or idxHash shl 1; // 7
                                  end;
                               end;
                               *)
                      end;
                   end;
     
     
                   ProgressBarCompresse.StepBy(AmtCompressed);
                   BlockWrite(FichierPack, BlockPack, BlockPackLen);
     
     
                end;
     
             finally
                CloseFile(FichierPack);
             end;
          finally
             CloseFile(FichierOri);
          end;
       finally
          BtnCompresserByteHash.Enabled := True;
       end;
    end;
     
    procedure TFrmTestFichier.BtnDeCompresserByteHashClick(Sender: TObject);
    begin
     //
    end;
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  4. #4
    Membre Expert

    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2007
    Messages
    3 530
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 530
    Par défaut
    Merci à vous feux !

    Shaï, je prends ton code pour une prochaine fois. Pour le projet concerné, il y a déjà des choses dans le format pour lequel je posais la question.
    Mais ça me sera utile dans les prochains mois.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 19/03/2008, 20h34
  2. Le résultat de Print ne s'affiche pas...
    Par Red Bull dans le forum Langage
    Réponses: 9
    Dernier message: 15/06/2006, 18h56
  3. Réponses: 3
    Dernier message: 18/05/2003, 00h16
  4. Réponses: 4
    Dernier message: 28/09/2002, 00h00
  5. [BDD] Enregistrer le résultat d'une requête
    Par Mowgly dans le forum C++Builder
    Réponses: 5
    Dernier message: 19/06/2002, 15h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo