- November 21, 2013 at 10:40 am #31552
HI, as the title said, I want to find a way to transcode png to pvrtc,
and I found PVRTexLib.lib, but it can only read pvr file.
how can I read png files and use PVRTexLib.lib to transcode it to pvrtc?November 21, 2013 at 4:12 pm #38236
PVRTexLib doesn’t have any way to natively handle image file formats. If you need to turn images into textures, you need to use a separate image processing library to do this. For png you can either use a low level library to do it, such as libpng, or something a bit more multipurpose like tinyimageloader. There’s a lot of image loading libraries out there if you don’t like the looks of either of those however!
Once you’ve loaded it into a raw bitmap, you can then put that data into a CPVRTexture by defining the header and passing in the raw data. If you have any questions about this step when you get there, let us know :)!
TobiasDecember 30, 2013 at 10:18 am #38238
I have loaded a png image using http://lodev.org/lodepng/ .
Now I have got a pointer ready to the raw data. From the loading code:
const char* filename = "test.png";
//load and decode
unsigned width, height;
unsigned error = lodepng::decode(image, width, height, filename);
// handle error
//the pixels are now in the vector "image", 4 bytes per pixel, ordered RGBARGBA..., use it as texture, draw it, ...
Now how can I load the data to a texture? Can I use `PVRTTexture` or do I have to write my own GL code?
Thanks for your help!January 2, 2014 at 10:53 am #38239
Are you talking about loading into a CPVRTexture for manipulation with PVRTexLib, or are you wanting to load it directly into OpenGL (ES) as a texture?
If you are looking to use it in OpenGL, you should load it directly with the OpenGL texture loading functions.