// //ORIGINAL LINE: Ogre::TexturePtr createTexture(Ogre::String name, Ogre::String group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) const // public TexturePtr createTexture(string name, string group) { Mogre.TexturePtr texture = TextureManager.Singleton.CreateManual(name, group, TextureType.TEX_TYPE_2D, mWidth, mHeight, 0, PixelFormat.PF_R8G8B8A8, (int)TextureUsage.TU_DEFAULT); Mogre.Image image = getImage(); texture.LoadImage(image); image.Dispose(); return(texture); }
//public unsafe void Replace3(Mogre.Image image, string textureName) //{ // if (this.IndexOf(textureName) < 0) throw new ArgumentException("The texture \"" + textureName + "\"doesn't exist"); // TexturePtr pTexture = this[textureName]; // HardwarePixelBufferSharedPtr texBuffer = pTexture.GetBuffer(); // texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD); // PixelBox pb = texBuffer.CurrentLock; // PixelBox imagBox = image.GetPixelBox(); // imagBox.data // Marshal.Copy(bytes, 0, pb.data, bytes.Length); // texBuffer.Unlock(); // texBuffer.Dispose(); //} public byte[] ConvertImageToRgbValues(byte[] inBytes) { Mogre.Image image = new Mogre.Image(); MemoryStream ms = new MemoryStream(inBytes); DataStreamPtr fs2 = new DataStreamPtr(new ManagedDataStream(ms)); image.Load(fs2); PixelBox imagBox = image.GetPixelBox(); uint bytes = imagBox.GetConsecutiveSize(); byte[] rgbValues = new byte[bytes]; Marshal.Copy(imagBox.data, rgbValues, 0, (int)bytes); image.Dispose(); fs2.Close(); ms.Close(); return(rgbValues); }
public void Replace(byte[] bytes, string textureName) { if (this.IndexOf(textureName) < 0) { throw new ArgumentException("The texture \"" + textureName + "\"doesn't exist"); } Mogre.Image image = new Mogre.Image(); MemoryStream ms = new MemoryStream(bytes); DataStreamPtr fs2 = new DataStreamPtr(new ManagedDataStream(ms)); image.Load(fs2); PixelBox imagBox = image.GetPixelBox(); TexturePtr pTexture = this[textureName]; TextureManager lTextureManager = TextureManager.Singleton; HardwarePixelBuffer buffer = pTexture.GetBuffer(); unsafe { buffer.BlitFromMemory(imagBox); } image.Dispose(); fs2.Close(); ms.Close(); }
// * // \brief Save the image from the buffer to a file. // \param filename Name (and path) of the image file where to save the buffer. // // //ORIGINAL LINE: void saveImage(Ogre::String filename) const public void saveImage(string filename) { Mogre.Image image = getImage(); image.Save(filename); image.Dispose(); }
public void Replace(byte[] bytes, string textureName) { if (this.IndexOf(textureName) < 0) throw new ArgumentException("The texture \"" + textureName + "\"doesn't exist"); Mogre.Image image = new Mogre.Image(); MemoryStream ms = new MemoryStream(bytes); DataStreamPtr fs2 = new DataStreamPtr(new ManagedDataStream(ms)); image.Load(fs2); PixelBox imagBox = image.GetPixelBox(); TexturePtr pTexture = this[textureName]; TextureManager lTextureManager = TextureManager.Singleton; HardwarePixelBuffer buffer = pTexture.GetBuffer(); unsafe { buffer.BlitFromMemory(imagBox); } image.Dispose(); fs2.Close(); ms.Close(); }
//public unsafe void Replace3(Mogre.Image image, string textureName) //{ // if (this.IndexOf(textureName) < 0) throw new ArgumentException("The texture \"" + textureName + "\"doesn't exist"); // TexturePtr pTexture = this[textureName]; // HardwarePixelBufferSharedPtr texBuffer = pTexture.GetBuffer(); // texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD); // PixelBox pb = texBuffer.CurrentLock; // PixelBox imagBox = image.GetPixelBox(); // imagBox.data // Marshal.Copy(bytes, 0, pb.data, bytes.Length); // texBuffer.Unlock(); // texBuffer.Dispose(); //} public byte[] ConvertImageToRgbValues(byte[] inBytes) { Mogre.Image image = new Mogre.Image(); MemoryStream ms = new MemoryStream(inBytes); DataStreamPtr fs2 = new DataStreamPtr(new ManagedDataStream(ms)); image.Load(fs2); PixelBox imagBox = image.GetPixelBox(); uint bytes = imagBox.GetConsecutiveSize(); byte[] rgbValues = new byte[bytes]; Marshal.Copy(imagBox.data, rgbValues, 0, (int)bytes); image.Dispose(); fs2.Close(); ms.Close(); return rgbValues; }