PVR Conversion/Generation

This topic contains 4 replies, has 2 voices, and was last updated by  Dark 8 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29704

    Dark
    Member

    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.
    #32729

    Gordon
    Moderator

    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.

    #32730

    Dark
    Member

    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. 
    #32731

    Gordon
    Moderator

    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:

    for(int i=0;i<numPixels;i++)

    {

         *pOutput = (uint16) (     

              ((pInput->Red & 0xf8)<<8)     |

              ((pInput->Green & 0xfc)<<3)     |

              ((pInput->Blue   & 0xf8)>>3)     

              );

    }

    or similar.

    #32732

    Dark
    Member

    Yes, I found the IJG sdk.

    Thanks for the hint about loading the pixel buffers my self, that will work nicely.

    I’ll have to give it a shot now, I’ll post an update.

     

    Thank you, Dimitry.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.