Game Development Community

How can I save a image file from one format to another in TorqueScript?

by Vince Gee · in Torque 3D Professional · 10/10/2013 (5:22 am) · 3 replies

Lets say I have a DDS for a texture and I want to export it as a BMP(or any other format) and save it. Does anyone know how to do this via TorqueScript or C++? I want the ability to allow people to export stuff to different formats.

Vince

#1
10/10/2013 (6:57 am)
So far the code is looking like:

extern "C" __declspec(dllexport) void __cdecl TestFileExport()
	{
		//GFXTextureProfile* profile;
	 BitStream* tempStream = BitStream::getPacketStream(4294967295);
	 GFXTexHandle* mTextureObject = new GFXTexHandle("art/terrains/Example/Empty Terrain_0_basetex",&GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
	 mTextureObject->getBitmap()->writeBitmap("JPG",*tempStream);
	 delete mTextureObject;
	 delete tempStream;
	}

I'm working until I hit the "writeBitMap" command.

and it blows up at

GFXFormat   getFormat() const { return mInternalFormat; }
#2
10/10/2013 (7:12 am)
Ok, did some more digging,

//GFXTextureProfile* profile;
	 BitStream* tempStream = BitStream::getPacketStream(4294967295);
	 GFXTexHandle* mTextureObject = new GFXTexHandle("art/terrains/Example/Empty Terrain_0_basetex",&GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));

	 GBitmap* bm = mTextureObject->getBitmap();

	 mTextureObject->getBitmap()->writeBitmap("BMP",*tempStream);
	 delete mTextureObject;
	 delete tempStream;

The getBitMap() function is returning null... why?
#3
10/10/2013 (7:14 am)
Hi Vince,

Is the texture stored in system memory? Look at its profile, and change it if needed. I *think* GFXDefaultGUIProfile only stores the texture in video RAM, though it's like 4 years since I checked.