Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. use qUncompress to uncompress data compressed by zlib with another application
Forum Updated to NodeBB v4.3 + New Features

use qUncompress to uncompress data compressed by zlib with another application

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hi,

    I have two applications. One is written in delphi, which is compressing data with zlib.
    The other one is written in c++ which should uncompress this data.

    In detail:
    In delphi I create a file compress it and add a 4 byte header to the compressed data:

      destStream := TFileStream.Create(SaveDialog1.FileName, fmCreate);
      destStream.WriteData(sourceStream.Size, 4);  // here I add the header for qUncompress
      sourceStream.Seek(0, soFromBeginning);
      LZip := TZCompressionStream.Create(clMax, destStream);
      LZip.CopyFrom(sourceStream, sourceStream.Size);
    

    In QT i try to uncompress this data like this:

        QFile file("E:\\Temp\\wheels\\test.adb");
        if (!file.open(QIODevice::ReadOnly))
            return;
    
        QByteArray compressed = file.readAll();
        qDebug() << "Compresed=" << compressed.size();
    
        QByteArray uncompressed = qUncompress(compressed); // HERE I GET: qUncompress: Input data is corrupted
        qDebug() << "UnCompresed=" << uncompressed.size();
    

    Any idea what I'm doing wrong?
    Unfortunately I haven't seen the source of qUncompress yet. So don't know what it is expecting.

    THX
    mts

    raven-worxR 1 Reply Last reply
    0
    • T themts

      Hi,

      I have two applications. One is written in delphi, which is compressing data with zlib.
      The other one is written in c++ which should uncompress this data.

      In detail:
      In delphi I create a file compress it and add a 4 byte header to the compressed data:

        destStream := TFileStream.Create(SaveDialog1.FileName, fmCreate);
        destStream.WriteData(sourceStream.Size, 4);  // here I add the header for qUncompress
        sourceStream.Seek(0, soFromBeginning);
        LZip := TZCompressionStream.Create(clMax, destStream);
        LZip.CopyFrom(sourceStream, sourceStream.Size);
      

      In QT i try to uncompress this data like this:

          QFile file("E:\\Temp\\wheels\\test.adb");
          if (!file.open(QIODevice::ReadOnly))
              return;
      
          QByteArray compressed = file.readAll();
          qDebug() << "Compresed=" << compressed.size();
      
          QByteArray uncompressed = qUncompress(compressed); // HERE I GET: qUncompress: Input data is corrupted
          qDebug() << "UnCompresed=" << uncompressed.size();
      

      Any idea what I'm doing wrong?
      Unfortunately I haven't seen the source of qUncompress yet. So don't know what it is expecting.

      THX
      mts

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @themts said:

      Unfortunately I haven't seen the source of qUncompress yet. So don't know what it is expecting.

      Here you go

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • T Offline
        T Offline
        themts
        wrote on last edited by
        #3

        Thanks, that already helped.
        I just forgot to swap endian.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          KArchive is the best free code available to handle compressed files

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved