Extract embedded resources
-
wrote on 20 Feb 2012, 11:03 last edited by
Hi I'm new to Qt and have been trying it out with simple apps. I compiled some jpegs in to an EXE file, which I now need to extract as the original images are lost due to a hard disk crash. Is there a Qt utility which would help me do that?
Many thanks. -
wrote on 20 Feb 2012, 12:27 last edited by
Good question. Gammaray (by KDAB) is able to display the resources, but I did not see an option to extract them. Still, that should be an easy enough addition, and the tool is open source.
-
wrote on 20 Feb 2012, 16:15 last edited by
If you need utility to extract images, you can try Restorator 2007.
If you need sample how to do that in Qt, look "here":http://developer.qt.nokia.com/doc/qt-4.8/qresource.html -
wrote on 20 Feb 2012, 16:22 last edited by
I don't see an example of using Resorator on that page?
-
wrote on 20 Feb 2012, 16:25 last edited by
Who has told where is an example using Restorator on that page? O_o
-
wrote on 20 Feb 2012, 16:29 last edited by
[quote author="AcerExtensa" date="1329755145"]Who has told where is an example using Restorator on that page? O_o
[/quote]
Well, if my understanding of the English language is correct (I am not a native speaker, so I might be off), the highlighted 'that' in the second sentence of the quote below refers to the 'extracting of images' from the first sentence.
[quote author="AcerExtensa" date="1329754537"]If you need utility to extract images, you can try Restorator 2007.
If you need sample how to do that in Qt, look "here":http://developer.qt.nokia.com/doc/qt-4.8/qresource.html[/quote]Hence, in my understanding, you wrote that there would be an example of extracting images behind the link. Otherwise, what does 'that' refer to exactly?
-
wrote on 20 Feb 2012, 16:36 last edited by
ahm, but I wrote "how to do that in Qt . ", and not just "how to do that . "
But, maybe you are right, I'm not native english speaker too :DAnyway, with
bq. how to do that in Qt
I meant, how to extract Resources from Libraries(etc...) with help of Qt Framework... :D
-
wrote on 20 Feb 2012, 23:09 last edited by
If you look at the qrc_xxx.cpp source file, it contains some static data. The actual images are in qt_resource_data. One could try to find the offeset in the executable at wich that block of data starts and then read the data out of the file. The format is quite simple.
-
wrote on 21 Feb 2012, 19:12 last edited by
Thanks for all who are contributing to this topic. Unfortunately I haven't had any joy with any of the suggestions. I have now gone down the route of using a hex editor to edit the EXE file and extract the required jpeg sections by identifying the start and end markers FFD8 and FFD9 respectively of an embedded jpeg. However the resulting jpeg file is being reported as corrupt and am unable to open it using many different graphics applications. I guess the reason for that is because the header information which should identify the file as jpeg i.e. JFIF is either missing or was converted at compile time to something which is specific to Qt environment only.
Good header: FF D8 FF E0 00 10 4A 46 49 46 00 01 00 01 01 2C where 4A 46 49 46 corresponds to JFIF.
Not-so-good header (from my EXE file): FF D8 70 79 09 59 26 2A 60 46 AC F7 00 as you can see the 4 bytes (4A 46 49 46) corresponding to JFIF in the good header is missing here.
Does anyone know if Qt manipulates jpeg headers before embedding them in to EXE files? -
wrote on 21 Feb 2012, 19:31 last edited by
The files are stored "as is". qrc does not manipulate the contents. While stand alone qrc files (to be loaded after application startup) can be compressed, the compiled in resources are one to one copies of the bytes of the files on the disk. For qrc it's only files, it is not aware of the concept of images or the like.
1/10