Create PNG Image from raw png data

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
abhilashk_cse
Posts: 3
Joined: Mon Apr 19, 2010 2:20 pm

Create PNG Image from raw png data

Post by abhilashk_cse »

Is it possible to create PNG image from raw png bytes data?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm :? :roll:
abhilashk_cse
Posts: 3
Joined: Mon Apr 19, 2010 2:20 pm

Post by abhilashk_cse »

I dont mind whether it is PNG or JPEG. Please check this out http://www.andrewewhite.net/wordpress/2 ... er-in-c-c/

If somebody can read the data from memory buffer and create the Image it will be great.
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

I think Hybrid was hmming at the fact that you look like a spam bot.

If you're not a spam bot, then look around a little better next time
http://irrlicht.sourceforge.net/docu/cl ... 666c8436c0

~David
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, I was just wondering why it is so difficult to create a PNG image from PNG bytes. For me this sounds like just dumping the bytes into a file. Now it looks as if the pixel data (ARGB or so) should be written to a PNG file or whatever format. That's the job of the IImageWriter classes, so just use those. Code can be found in the examples/Demo.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

To be a bit more precise one way to go:

Code: Select all

IImage* img = driver->createImage(ECF_A8R8G8B8, dimension2du(width, height);
memcpy(img->lock(), data, sizeofdata);
img->unlock();
driver->writeImageToFile(img, "dummy.png");
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Nox wrote:To be a bit more precise one way to go:

Code: Select all

IImage* img = driver->createImage(ECF_A8R8G8B8, dimension2du(width, height);
memcpy(img->lock(), data, sizeofdata);
img->unlock();
driver->writeImageToFile(img, "dummy.png");
won't work! bc this doesn't expect png format.

you will have to create a memory read file and pass that to the image loader function. but right now i am to lazy to look up the code.

EDIT: ok..well

Code: Select all

//name the file something *.png so the irrlicht loader knows its a png
IReadFile* file = filesystem->createMemoryReadFile(YourMemory, Length, "something.png", false);
IImage* myImage = videoDriver->createImageFromFile(file);

//then add a texture
videoDriver->addTexture("myNewPngTexture.png", myImage);
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply