예제 #1
0
 public static void Scale(IntPtr data, Vector2I size, PixelFormat format, Vector2I newSize, Filters filter, IntPtr newData)
 {
     unsafe
     {
         OgreImageManager.scale(RenderingSystem.realRoot, data, size.X, size.Y, format, newSize.X, newSize.Y, filter, newData);
     }
 }
예제 #2
0
        /////////////////////////////////////////

        /// <summary>
        /// Loads an image file.
        /// </summary>
        /// <param name="virtualFileName">The virtual file name.</param>
        /// <param name="data">The image data.</param>
        /// <param name="size">The image size.</param>
        /// <param name="depth">The image depth (in 3d images, numbers of layers, otherwhise 1).</param>
        /// <param name="format">Pixel format.</param>
        /// <param name="numFaces">The number of faces the image data has inside (6 for cubemaps, 1 otherwise).</param>
        /// <param name="numMipmaps">The number of mipmaps the image data has inside.</param>
        /// <param name="error">Output error string.</param>
        /// <returns><b>true</b> if image is loaded; otherwise, <b>false</b>.</returns>
        public static bool LoadFromVirtualFile(string virtualFileName, out byte[] data, out Vector2I size, out int depth,
                                               out PixelFormat format, out int numFaces, out int numMipmaps, out string error)
        {
            unsafe
            {
                IntPtr pData;
                int    dataSize;
                int    width;
                int    height;
                IntPtr errPointer;

                bool result = OgreImageManager.loadFromFile(RenderingSystem.realRoot, virtualFileName, out pData,
                                                            out dataSize, out width, out height, out depth, out format, out numFaces,
                                                            out numMipmaps, out errPointer);
                string err = OgreNativeWrapper.GetOutString(errPointer);

                error = null;
                data  = null;
                size  = new Vector2I(width, height);

                if (err != null)
                {
                    error = string.Format("Loading file failed \"{0}\" ({1}).", virtualFileName, err);
                }

                if (pData != IntPtr.Zero)
                {
                    data = new byte[dataSize];
                    Marshal.Copy(pData, data, 0, data.Length);
                    OgreImageManager.freeData(RenderingSystem.realRoot, pData);
                }

                return(result);
            }
        }
예제 #3
0
        public static void Scale(byte[] data, Vector2I size, PixelFormat format, Vector2I newSize, Filters filter, out byte[] newData)
        {
            newData = new byte[newSize.X * newSize.Y * PixelFormatUtility.GetNumElemBytes(format)];

            unsafe
            {
                fixed(byte *pData = data, pNewData = newData)
                {
                    OgreImageManager.scale(RenderingSystem.realRoot, (IntPtr)pData, size.X, size.Y, format, newSize.X, newSize.Y, filter, (IntPtr)pNewData);
                }
            }
        }
예제 #4
0
        public static bool GetImageFlags(string realFileName, out ImageFlags flags, out string error)
        {
            error = null;

            unsafe
            {
                bool   result = OgreImageManager.getImageFlags(RenderingSystem.realRoot, realFileName, out uint uflags, out IntPtr errPointer);
                string err    = OgreNativeWrapper.GetOutString(errPointer);
                if (err != null)
                    error = string.Format("Error in file \"{0}\" ({1}).", realFileName, err); }

                flags = (ImageFlags)uflags;

                return(result);
            }
예제 #5
0
        /// <summary>
        /// Save the image as a file.
        /// </summary>
        /// <param name="realFileName">The real file name.</param>
        /// <param name="data">The image data.</param>
        /// <param name="size">The image size.</param>
        /// <param name="depth">The image depth (in 3d images, numbers of layers, otherwhise 1).</param>
        /// <param name="format">Pixel format.</param>
        /// <param name="numFaces">The number of faces the image data has inside (6 for cubemaps, 1 otherwise).</param>
        /// <param name="numMipmaps">The number of mipmaps the image data has inside.</param>
        /// <param name="error">Output error string.</param>
        /// <returns><b>true</b> if image is currently serialized; otherwise, <b>false</b>.</returns>
        public static bool Save(string realFileName, IntPtr data, Vector2I size, int depth, PixelFormat format,
                                int numFaces, int numMipmaps, out string error)
        {
            error = null;

            unsafe
            {
                IntPtr errPointer;
                bool   result = OgreImageManager.save(RenderingSystem.realRoot, realFileName, data,
                                                      size.X, size.Y, depth, format, numFaces, numMipmaps, out errPointer);
                string err = OgreNativeWrapper.GetOutString(errPointer);
                if (err != null)
                {
                    error = string.Format("Saving file failed \"{0}\" ({1}).", realFileName, err);
                }
                return(result);
            }
        }
예제 #6
0
        /// <summary>
        /// Loads an image from buffer.
        /// </summary>
        /// <param name="sourceBuffer">The source buffer.</param>
        /// <param name="fileType">The file type (file extension).</param>
        /// <param name="data">The image data.</param>
        /// <param name="size">The image size.</param>
        /// <param name="depth">The image depth (in 3d images, numbers of layers, otherwhise 1).</param>
        /// <param name="format">Pixel format.</param>
        /// <param name="numFaces">The number of faces the image data has inside (6 for cubemaps, 1 otherwise).</param>
        /// <param name="numMipmaps">The number of mipmaps the image data has inside.</param>
        /// <param name="error">Output error string.</param>
        /// <returns><b>true</b> if image is loaded; otherwise, <b>false</b>.</returns>
        public static bool LoadFromBuffer(byte[] sourceBuffer, string fileType, out byte[] data,
                                          out Vector2I size, out int depth, out PixelFormat format, out int numFaces,
                                          out int numMipmaps, out string error)
        {
            unsafe
            {
                IntPtr pData;
                int    dataSize;
                int    width;
                int    height;
                IntPtr errPointer;

                bool result;
                fixed(byte *pSourceBuffer = sourceBuffer)
                {
                    result = OgreImageManager.loadFromBuffer(RenderingSystem.realRoot,
                                                             (IntPtr)pSourceBuffer, sourceBuffer.Length, fileType, out pData, out dataSize,
                                                             out width, out height, out depth, out format, out numFaces, out numMipmaps,
                                                             out errPointer);
                }

                string err = OgreNativeWrapper.GetOutString(errPointer);

                error = null;
                data  = null;
                size  = new Vector2I(width, height);

                if (err != null)
                {
                    error = string.Format("Loading file from buffer failed ({0}).", err);
                }

                if (pData != IntPtr.Zero)
                {
                    data = new byte[dataSize];
                    Marshal.Copy(pData, data, 0, data.Length);
                    OgreImageManager.freeData(RenderingSystem.realRoot, pData);
                }

                return(result);
            }
        }