Hi all.
It would be very usefull to be able to use .NET Bitmap objects as a textures(ITexture).
If I understood correctly from examples, actual images are loaded into IImage objects and then ITexture objects are from them to be able to reproduce in 3D.
I'm using FreeImage lib to load plenty image formats as .NET bitmap objects, but cannot use them since Irrlicht doesn't support .NET Bitmaps.
Supposingly it would be nice to look something like this:
driver->getTexture(System.Draving.Bitmap _imageToUseAsTexture);
Another thing would be great to be able to convert from ITexture to .NET Bitmap.
Anyway this would be really helpfull implementations for .NET community of Irrlicht engine.
Nikko, thanks for a great engine, can't wait when all functionallity will be implemented in a .NET version of this remarkable engine.
CroDude
Feat.Req: .NET Bitmap object to Irrlicht IImage
http://irrlicht.sourceforge.net/docu/cl ... xture.html
http://irrlicht.sourceforge.net/docu/cl ... image.html
http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/
Now you have access to the same information I have... Enjoy.
http://irrlicht.sourceforge.net/docu/cl ... image.html
http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/
Now you have access to the same information I have... Enjoy.

I've been investigating a bit into Irrlicht source code and docs and some thought came to my mind ... but I'm not a C++ coder so correct me if I'm wrong.
I suppose that all to coding should be in a .NET wrapper since this has nothing to do with Irrlicht for C++.
In a .NET wrapper in IVideoDriver class wrapping there should be added method something like this (This is a pseudo code):
ITexture IVideoDriver.AddTexture(System.Drawing.Bitmap _NETBitmapObject)
{
// Return null if empty object
if(_NETBitmapObject == null) return null;
// GetPixelFormat of the NET image
System.Drawing.Imaging.PixelFormat pixelFormat = _NETBitmapObject.PixelFormat;
int imageDepth = // Get image depth from pixelFormat object ... I'm to lazy to write all that here, but this is trivial
// Get dimension of the image
int dimension = _NETBitmapObject.Width * _NETBitmapObject.Height * imageDepth;
// Get the BitmapData object by locking a NET bitmap in memory
System.Drawing.Imaging.BitmapData bitmapData = _NETBitmapObject.LockBits();
IImage* irrImage;
irrImage = createImageFromData( format???, dimension, *bitmapData, false);
ITexture* irrTexture;
irrTexture = addTexture("NewTexture", *irrImage);
// Unlock NET bitmap
_NETBitmapObject.UnlockBits();
return irrTexture;
}
Well from here I could see that there will be problems in createImageFromData function regarding format and dimension.
Format should be converted to a image format enum that Irrlicht recognizes
and from function prototype, dimension should be:
const core::dimension2d< s32 > type , so this int type dimension wouldn't work. This should also be converted to a type that irrLicht recognizes.
As I've said ... this is just a pseudo code(don't look if I wrote some pointer marks wrong, again I'm not a C++ coder), but should work when all will be polished.
Then, I hope that byte array(data) got form NET bitmap is compatibile with byte array that Irrlicht wants as a 'createImageFromData' function parameter.
I hope that someone with deeper knowledge with Irrlicht will be able to add some usefull comments on this so we can use NET Bitmap objects in Irrlicht.
I would gladly help with a FreeImage or Devil libs implementation so many image formats will be acceptable through them.
There are also posibilities to get ITextures straightly from FreeImage or Devil libs without need to use NET Bitmaps.
P.S. IntMain ... BMP is a image file format not System.Drawing.Bitmap type used in NET framework. heh
Many thanks!
I suppose that all to coding should be in a .NET wrapper since this has nothing to do with Irrlicht for C++.
In a .NET wrapper in IVideoDriver class wrapping there should be added method something like this (This is a pseudo code):
ITexture IVideoDriver.AddTexture(System.Drawing.Bitmap _NETBitmapObject)
{
// Return null if empty object
if(_NETBitmapObject == null) return null;
// GetPixelFormat of the NET image
System.Drawing.Imaging.PixelFormat pixelFormat = _NETBitmapObject.PixelFormat;
int imageDepth = // Get image depth from pixelFormat object ... I'm to lazy to write all that here, but this is trivial
// Get dimension of the image
int dimension = _NETBitmapObject.Width * _NETBitmapObject.Height * imageDepth;
// Get the BitmapData object by locking a NET bitmap in memory
System.Drawing.Imaging.BitmapData bitmapData = _NETBitmapObject.LockBits();
IImage* irrImage;
irrImage = createImageFromData( format???, dimension, *bitmapData, false);
ITexture* irrTexture;
irrTexture = addTexture("NewTexture", *irrImage);
// Unlock NET bitmap
_NETBitmapObject.UnlockBits();
return irrTexture;
}
Well from here I could see that there will be problems in createImageFromData function regarding format and dimension.
Format should be converted to a image format enum that Irrlicht recognizes
and from function prototype, dimension should be:
const core::dimension2d< s32 > type , so this int type dimension wouldn't work. This should also be converted to a type that irrLicht recognizes.
As I've said ... this is just a pseudo code(don't look if I wrote some pointer marks wrong, again I'm not a C++ coder), but should work when all will be polished.
Then, I hope that byte array(data) got form NET bitmap is compatibile with byte array that Irrlicht wants as a 'createImageFromData' function parameter.
I hope that someone with deeper knowledge with Irrlicht will be able to add some usefull comments on this so we can use NET Bitmap objects in Irrlicht.
I would gladly help with a FreeImage or Devil libs implementation so many image formats will be acceptable through them.
There are also posibilities to get ITextures straightly from FreeImage or Devil libs without need to use NET Bitmaps.
P.S. IntMain ... BMP is a image file format not System.Drawing.Bitmap type used in NET framework. heh

Many thanks!
A minor mistake happened. Here's correction:
IImage* irrImage;
irrImage = createImageFromData( format???, dimension, *bitmapData.Scan0, false);
Link with some examples of unsafe image processing in .NET(C#):
http://msdn.microsoft.com/library/defau ... 152001.asp
IImage* irrImage;
irrImage = createImageFromData( format???, dimension, *bitmapData.Scan0, false);
Link with some examples of unsafe image processing in .NET(C#):
http://msdn.microsoft.com/library/defau ... 152001.asp