Пример #1
0
        //private static object theming_ref;    //holds a reference to a theming object in windows so that its not garbage collected

        public static Result Open()
        {
            AppendWindowsPath();

            //EnableThemingInScope.EnableThemingInWindows();
            Result res = (Result)NativeIUP.IupOpen(IntPtr.Zero, IntPtr.Zero);


            // In .NET we always want unicode
            Iup.SetStrGlobal("UTF8MODE", "YES");
            Iup.SetStrGlobal("UTF8MODE_FILE", "YES");

            return(res);
        }
Пример #2
0
        //private static object theming_ref;    //holds a reference to a theming object in windows so that its not garbage collected

        public static Result Open()
        {
            int siz = IntPtr.Size;



            // Add search path first to path system variable
            string exe = Environment.GetCommandLineArgs()[0];


            //EnableThemingInScope.EnableThemingInWindows();
            Result res = (Result)NativeIUP.IupOpen(IntPtr.Zero, IntPtr.Zero);


            // In .NET we always want unicode
            Iup.SetStrGlobal("UTF8MODE", "YES");
            Iup.SetStrGlobal("UTF8MODE_FILE", "YES");

            return(res);
        }
Пример #3
0
        /// <summary>
        /// Creates an IUP image using a System.Drawing.Bitmap
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        public static IupHandle ImageFromBitmap(Bitmap bmp)
        {
            //TODO: try for diffrent bit depths / optimize with bitmap locking
            int w = bmp.Width, h = bmp.Height;

            if (w < 1 || h < 1)
            {
                return(null);
            }
            IupHandle res;
            bool      alpha = bmp.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb;

            if (alpha)
            {
                res = Iup.ImageRGBA(w, h, null);
            }
            else
            {
                res = Iup.ImageRGB(w, h, null);
            }

            int    idx = 0;
            IntPtr pix = res.GetAttribute("WID");

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    var col = bmp.GetPixel(x, y);
                    Marshal.WriteByte(pix, idx++, col.R);
                    Marshal.WriteByte(pix, idx++, col.G);
                    Marshal.WriteByte(pix, idx++, col.B);
                    if (alpha)
                    {
                        Marshal.WriteByte(pix, idx++, col.A);
                    }
                }
            }

            return(res);
        }