Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Texture2D() [6/6]

unsafe Microsoft.Xna.Framework.Graphics.Texture2D.Texture2D ( GraphicsDevice graphicsDevice,
Stream stream,
int width,
int height,
SharedConstants::XnaImageOperation operation )
inlinepackage

Definition at line 114 of file Texture2D.cs.

115 {
116 try
117 {
118 if (graphicsDevice == null)
119 {
120 throw new ArgumentNullException("graphicsDevice", FrameworkResources.DeviceCannotBeNullOnResourceCreate);
121 }
122 if (stream == null)
123 {
124 throw new ArgumentNullException("stream", FrameworkResources.NullNotAllowed);
125 }
126 if (!stream.CanSeek)
127 {
128 throw new ArgumentException(FrameworkResources.StreamNotSeekable, "stream");
129 }
130 ValidateCreationParameters(graphicsDevice._profileCapabilities, width, height, SurfaceFormat.Color, mipMap: false);
131 ImageStream imageStream = stream as ImageStream;
132 try
133 {
134 if (imageStream == null)
135 {
136 imageStream = ImageStream.FromStream(stream);
137 }
138 void* ptr = null;
139 Helpers.ThrowExceptionFromErrorCode(Microsoft.Xna.Framework.Media.UnsafeNativeMethods.DecodeStreamToTexture(graphicsDevice.pComPtr, imageStream.Handle, &width, &height, (XnaImageOperation)operation, graphicsDevice._profileCapabilities.MaxTextureAspectRatio, &ptr));
140 pComPtr = (IDirect3DTexture9*)ptr;
141 }
142 finally
143 {
144 if (imageStream != null && imageStream != stream)
145 {
146 ((IDisposable)imageStream).Dispose();
147 }
148 }
149 isDisposed = false;
150 _parent = graphicsDevice;
151 SurfaceFormat? format = SurfaceFormat.Color;
153 graphicsDevice.Resources.AddTrackedObject(this, pComPtr, 1u, _internalHandle, ref _internalHandle);
154 return;
155 }
156 catch
157 {
158 //try-fault
159 base.Dispose(true);
160 throw;
161 }
162 }
static void ValidateCreationParameters(ProfileCapabilities profile, int width, int height, SurfaceFormat format, [MarshalAs(UnmanagedType.U1)] bool mipMap)
Definition Texture2D.cs:633
unsafe IDirect3DTexture9 * pComPtr
Definition Texture2D.cs:22
unsafe void InitializeDescription(SurfaceFormat? format)
Definition Texture2D.cs:589

References Microsoft.Xna.Framework.Graphics.GraphicsResource._internalHandle, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.Graphics.DeviceResourceManager.AddTrackedObject(), Microsoft.Xna.Framework.FrameworkResources.DeviceCannotBeNullOnResourceCreate, System.format, Microsoft.Xna.Framework.Graphics.Texture2D.InitializeDescription(), Microsoft.Xna.Framework.Graphics.GraphicsResource.isDisposed, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxTextureAspectRatio, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.Texture2D.pComPtr, Microsoft.Xna.Framework.Graphics.GraphicsDevice.Resources, System.stream, Microsoft.Xna.Framework.FrameworkResources.StreamNotSeekable, Microsoft.Xna.Framework.Helpers.ThrowExceptionFromErrorCode(), and Microsoft.Xna.Framework.Graphics.Texture2D.ValidateCreationParameters().