Storing PFG_R16_UNORM Texture crash

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Lax
Gnoll
Posts: 683
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 65

Storing PFG_R16_UNORM Texture crash

Post by Lax »

Hi,

I don't know, it this is already fixed, but when I try to store a texture with the format PFG_R16_UNORM . I get a Heap corruption crash in FreeImage.
When I store a texture in PFG_R8_UNORM format, it does not crash and a valid texture will be stored.

I tested it in terra, in the function "createHeightmap".

Code: Select all

m_heightMapTex->writeContentsToFile("path/TestHeightMap.png", 0, m_heightMapTex->getNumMipmaps());
Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: Storing PFG_R16_UNORM Texture crash

Post by Eugene »

Thank you for reporting, fixed.
Lax
Gnoll
Posts: 683
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 65

Re: Storing PFG_R16_UNORM Texture crash

Post by Lax »

Ok thanks, now it works.

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Lax
Gnoll
Posts: 683
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 65

Re: Storing PFG_R16_UNORM Texture crash

Post by Lax »

Hi Eugene,

I found another strange behavior.
When I store a PFG_RGBA8_UNORM image, internally the format:
from PFG_RGBA8_UNORM
to PFG_BGRA8_UNORM

Which causes errors when loading, since the rgba has been swapped. I found out, that it happens during "writeContentsToFile" in "OgreFreeImageCodec2.cpp":

Code: Select all

        case PFG_RGBA8_UNORM:
        case PFG_RGBA8_UNORM_SRGB:
        case PFG_RGBA8_UINT:
        case PFG_RGBA8_SNORM:
        case PFG_RGBA8_SINT:
#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
            // typeless RGBA => BGRA conversion
            origFormat = PFG_RGBA8_UNORM;
            supportedFormat = PFG_BGRA8_UNORM;
#else
            // typeless RGBA => RGBA conversion
            origFormat = PFG_RGBA8_UNORM;
            supportedFormat = PFG_RGBA8_UNORM;
#endif
I have no idea why FREEIMAGE_COLORORDER_BGR is defined? Is this on purpose?

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62