Exemple #1
0
        public string AsBase64Png()
        {
            int    numBytes;
            IntPtr mem = SimpleImageIOCore.WritePngToMemory(data, Width, Height, 3, out numBytes);

            byte[] bytes = new byte[numBytes];
            Marshal.Copy(mem, bytes, 0, numBytes);
            SimpleImageIOCore.FreeMemory(mem);

            return(Convert.ToBase64String(bytes));
        }
Exemple #2
0
        public void WriteToFile(string filename)
        {
            // First, make sure that the full path exists
            var dirname = System.IO.Path.GetDirectoryName(filename);

            if (dirname != "")
            {
                System.IO.Directory.CreateDirectory(dirname);
            }

            SimpleImageIOCore.WriteImage(data, Width, Height, 3, filename);
        }
Exemple #3
0
        void LoadFromFile(string filename)
        {
            // Read the image from the file, it is cached in native memory
            int width, height;
            int id = SimpleImageIOCore.CacheImage(out width, out height, filename);

            if (id < 0)
            {
                throw new System.IO.IOException($"ERROR: Could not load image file '{filename}'");
            }

            // Copy to managed memory array
            data = new Vector3[height, width];
            SimpleImageIOCore.CopyCachedImage(id, data);
        }