public override void SetSourceSurface(SurfaceImpl surf, Rectangle srcRect) { ReleaseTextureRef(); AddTextureRef((surf as GL_Surface).mTextureID); mTextureSize = (surf as GL_Surface).mTextureSize; mSourceRect = srcRect; mTexCoord = GetTextureCoords(mSourceRect); }
/// <summary> /// Creates a surface object of the specified size. /// </summary> /// <param name="size"></param> public Surface(Size size) { if (Display.Impl == null) { throw new AgateException("AgateLib's display system has not been initialized."); } impl = Display.Impl.CreateSurface(size); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); }
public override void SetSourceSurface(SurfaceImpl surf, Rectangle srcRect) { mTexture.Dispose(); mTexture = new Ref <Texture>((surf as SDX_Surface).mTexture); mSrcRect = srcRect; Direct3D.Surface d3dsurf = mTexture.Value.GetSurfaceLevel(0); mTextureSize = new Size(d3dsurf.Description.Width, d3dsurf.Description.Height); SetVertsTextureCoordinates(mVerts, 0, mSrcRect); }
public override void SetSourceSurface(SurfaceImpl surf, Geometry.Rectangle srcRect) { mImage.Dispose(); mImage = new Bitmap(srcRect.Width, srcRect.Height); Graphics g = Graphics.FromImage(mImage); g.DrawImage((surf as Drawing_Surface).mImage, new Rectangle(Point.Empty, Interop.Convert(srcRect.Size)), Interop.Convert(srcRect), GraphicsUnit.Pixel); g.Dispose(); }
/// <summary> /// Creates a surface object from a resource. /// </summary> /// <param name="resources"></param> /// <param name="name"></param> public Surface(Resources.AgateResourceCollection resources, string name) { if (Display.Impl == null) { throw new AgateException("AgateLib's display system has not been initialized."); } Resources.AgateResource res = resources[name]; Resources.SurfaceResource surf = res as Resources.SurfaceResource; impl = resources.LoadSurfaceImpl(surf.Filename); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); }
/// <summary> /// Creates a surface object using the specified file provider to open the image file. /// </summary> /// <param name="filename"></param> /// <param name="fileProvider"></param> public Surface(IFileProvider fileProvider, string filename) { if (Display.Impl == null) { throw new AgateException("AgateLib's display system has not been initialized."); } using (System.IO.Stream s = fileProvider.OpenRead(filename)) { impl = Display.Impl.CreateSurface(s); } Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); }
/// <summary> /// Creates a surface object and to be ready to attach to an implemented object. /// Throws an Exception if there is a passed impl. /// (This is not intended for use by applications). /// </summary> /// <param name="fromImpl"></param> internal Surface(SurfaceImpl fromImpl) { if (Display.Impl == null) { throw new AgateException("AgateLib's display system has not been initialized."); } if (fromImpl == null) { throw new ArgumentNullException("The argument fromImpl must not be null."); } Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); impl = fromImpl; }
internal SurfaceImpl LoadSurfaceImpl(string filename) { if (mOwnedSurfaces.ContainsKey(filename) == false) { string path = string.IsNullOrEmpty(RootDirectory)? filename : RootDirectory + "/" + filename; SurfaceImpl impl = Display.Impl.CreateSurface(FileProvider, path); mOwnedSurfaces.Add(filename, impl); return(impl); } else { return(mOwnedSurfaces[filename]); } }
/// <summary> /// Copies the pixels in this surface from the given source rectangle /// to a new surface, and returns that. /// It is not recommended to call this between calls to /// Display.BeginFrame..Display.EndFrame. /// </summary> /// <param name="srcRect">The rectangle of pixels to create a new surface from.</param> /// <returns>A Surface object containing only those pixels copied.</returns> public Surface CarveSubSurface(Rectangle srcRect) { SurfaceImpl newImpl = impl.CarveSubSurface(srcRect); return(new Surface(newImpl)); }