How to load texture from common picture formate?

This topic contains 10 replies, has 2 voices, and was last updated by  alvin 7 years, 5 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #30126

    alvin
    Member

    Hi,

      So far I only can load texture from PVR file according to the following API.

    PVRTTextureLoadFromPVR()

     

    Could I load texture from common picture formate such as *jpg, *bmp, *png and so on ?

     

    Does anyone have the similiar experience about this question ?

     

    Thank for your help.
    #33876

    Gordon
    Moderator

    You can load from other file formats, but you lose any advantages of the different texture formats that OpenGL ES allows you – i.e. everything will be 32bpp RGBA8888 or 24bpp RGB888 which is far from optimal for most situations. Compared this to 2bpp or 4bpp PVRTC, for instance.

    The procedure would be:

    – open file

    – read/decompress data -> RGBA8888

    – pass to GL

    The only advantage to be gained is in storage size (at least for png and jpg) and these formats can come directly from other sources than PVRTexTool.

    All the formats you mention can be converted to .PVR via PVRTexTool and with a little scripting this can be done automatically – see the SDK examples.

    Do you have a particular reason that you want to load directly from these formats?

    #33877

    alvin
    Member

    Hi,

      As you mentioned before,I know that I could convert .PNG (or .JPG) to .PVR via PVRTexTool in the SDK examples.

     

    Why do I want to load from these formats(*PNG or *JPG) directly?

    I would like to load those picture as texture directly.

    because those picture(*PNG or *JPG) were generated at run time.

     

    if I could load picture directly, I will save time.

    Because I don’t need  to spend time converting picture(*PNG or *JPG)  to .PVR file.

     

    If it’s possible,I want to load picture(*PNG or *JPG)  directly.

    If it is not possible.I only can load PRV file by converting picture to .PVR file.

     

    Does anyone have any idea about this question?

    Thank for your suggestion.

     

     

     

     

     
    #33878

    Gordon
    Moderator

    As I say above: the procedure would be:

    – open file

    – read/decompress data -> RGBA8888

    – pass to GL

    For instance: to read and decompress the data from a jpg, for instance, there are various libraries available in source:

    http://www.ijg.org/

    #33879

    alvin
    Member

    Hi Gordon,

       Could I confirm the precdedure?

     using PVRTexTool v3.10

    Step1:  File–>Open–>image.jpg

    Step2:  Edit–>Encode–>RGB888

     

     

    Does Step 1 map to – open file
    Does Step 2 map to – read/decompress data -> RGBA8888
    what is pass to GL?

     

    Could you please tell me more detail?

     

    Thanks for your help.

     
    #33880

    alvin
    Member

    Hi,

      I have read the article ” Load BMP file in runtime” in this forum.

    it memtions about using DevIL.

    we could load a .bmp(*jpg or *png) file as texture in runtime without converting into .PVR format.

    Is the above describtion correct?

    Or I just misunderstand it.

     

     

    Thanks

     
    #33881

    alvin
    Member

    Hi,

    on page 6 in the PVRTexTool.Reference Manual.1.11f.External.pdf

    An image file of the format (BMP, TGA, GIF, PCX, JPG and PNG). MIP-map information will
    be discarded when these formats are chosen – use Save MIP-level from the Edit menu for
    this functionality. A decompressed version of the encoded data that will be saved.

     

    According to the above step,I would save original bmp as new bmp file.

    This is what you memtion before.

     

    Thanks

     
    #33882

    Gordon
    Moderator

    If you want to use .jpg or .png or other image formats directly on your device then PVRTexTool can’t help you.

    You will have to write your own code to read these formats and then load the image data into OpenGL.

    The steps I described are the steps that your code would have to perform in order to do this.

    #33883

    alvin
    Member

    Thank you for your explanation.

     

    Maybe I don’t express my question clearly.

    What I want to confirm is that you had posted.

    PVRTexTool can’t help me to use .jpg or .png or other image formats directly on our device.

    We have to write our own code to read these formats and then load the image data into OpenGL.

     

    Thanks for your suggestion and help.

    According to your suggestion,I will try it.

     

    Thanks. Smile
    #33884

    Gordon
    Moderator

    Yes, that’s correct.

    #33885

    alvin
    Member

    Hi Gordon,

       According to your suggestion,I can use bmp file as texture directly base on SDK example.

     

    Thank you for your suggestion.
Viewing 11 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic.