- February 11, 2009 at 1:06 am #29704
Hello, I need to load JPG and BMP images at runtime. My target runs on linux so I am unable to use the PVRTexTool, is there source code for PVR file generation? Or atleast a file format specification document?Thank you, Dimitry.February 11, 2009 at 11:56 am #32729
Generating textures at runtime is going to add significantly to your application’s initialisation time and should be avoided if possible. It is better to prepare your textures beforehand.
However, if you examine the PVRTexTool and PVRTexLib documentation, there should be a description of the .PVR format. Note that .PVRs are container files that can host many different actual texture formats. Are you meaning PVRTC?
PVRTC compression source code is not available, decompression code is in the PVRTools/PVRTDecompress.* files available in our SDKs. There is also a white paper describing PVRTC. The compression of PVRTC textures is extremely slow and memory intensive on desktop hardware so I would suggest it is not suitable at runtime on a mobile device.
If you really must use runtime generated textures then it might be worth examining 16-bit formats such as RGB565 to see whether they satisfy the level of quality you require. You can use PVRTexTool GUI to preview the results of encoding to various formats.
Note also that PVRTexTool and PVRTexLib are actually both provided for Linux, but they are designed to be used on a development machine and not a target platform.February 11, 2009 at 5:26 pm #32730
Thanks for reply,Unfortunatly having ability to open images at runtime is mandatory for my scenario.I am not concerned with compression.I wanted to save my self some work by seeing if there is code or linux version of the TexTool.I did find the documentation you mentioned and RGB565 would be more then enough for what I need.So I gather it’s up to me if I want to load a JPG at runtime?Thanks, Dimitry.February 11, 2009 at 5:56 pm #32731
You’re correct – we don’t provide any code for reading JPGs at runtime in our SDK, I’m afraid.
I think your best bet would be to get libjpeg (which is what PVRTexTool uses under the hood to read images).
I believe the place to get this from is here: http://www.ijg.org/.
If you can build this for your platform then this library should allow you to read JPGs. You could conceivably assemble a PVR header from here and then use our PVRTools/PVRTTextureAPI code to load textures, but you are probably better off loading the decompressed data directly into GL(?) with your own routine. For better performance you may want to use RGB565 data instead of the 8 bits-per-channel data libjpeg will give you. It will require a fairly easy conversion; just mask off the bits you don’t need and shift them to the correct position pixel per pixel:Code:
*pOutput = (uint16) (
((pInput->Red & 0xf8)<<8) |
((pInput->Green & 0xfc)<<3) |
((pInput->Blue & 0xf8)>>3)