Esempio n. 1
0
        public Texture(string _mapPath, bool flipY = true)
        {
            using (Stream s = Interface.GetStreamFromPath(_mapPath)) {
                try {
                    Map = _mapPath;

                    Bitmap bitmap = new Bitmap(s);

                    if (flipY)
                    {
                        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }

                    BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                                      ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    createTexture(data.Scan0, data.Width, data.Height);

                    bitmap.UnlockBits(data);

                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

                    GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                } catch (Exception ex) {
                    Debug.WriteLine("Error loading texture: " + Map + ":" + ex.Message);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// load the image for rendering from the path given as argument
 /// </summary>
 /// <param name="path">image path, may be embedded</param>
 public override void Load(Interface iface, string path)
 {
     Path = path;
     if (sharedResources.ContainsKey(path))
     {
         sharedPicture sp = sharedResources [path];
         image      = (byte[])sp.Data;
         Dimensions = sp.Dims;
         return;
     }
     using (Stream stream = iface.GetStreamFromPath(path)) {
         loadBitmap(new System.Drawing.Bitmap(stream));
     }
     sharedResources [path] = new sharedPicture(image, Dimensions);
 }
Esempio n. 3
0
        public override void Load(Interface iface, string path)
        {
            Path = path;
            if (sharedResources.ContainsKey(path))
            {
                sharedPicture sp = sharedResources [path];
                hSVG       = (Rsvg.Handle)sp.Data;
                Dimensions = sp.Dims;
                return;
            }
            using (Stream stream = iface.GetStreamFromPath(path)) {
                using (MemoryStream ms = new MemoryStream()) {
                    stream.CopyTo(ms);

                    hSVG       = new Rsvg.Handle(ms.ToArray());
                    Dimensions = new Size(hSVG.Dimensions.Width, hSVG.Dimensions.Height);
                }
            }
            sharedResources [path] = new sharedPicture(hSVG, Dimensions);
        }
Esempio n. 4
0
 public IMLReader(string path)
     : this(Interface.GetStreamFromPath(path))
 {
     ImlPath = path;
 }
Esempio n. 5
0
        public void LoadImage(string path)
        {
            loadFromStream(Interface.GetStreamFromPath(path));

            Path = path;
        }
Esempio n. 6
0
 public static XCursorFile Load(Interface iface, string path)
 {
     return(loadFromStream(iface.GetStreamFromPath(path)));
 }