コード例 #1
0
ファイル: Surface.cs プロジェクト: hayate891/freetrain
 private static extern uint bltHueTransform(
     DirectDrawSurface7 lpDDSDest,
     DirectDrawSurface7 lpDDSSource,
     int iDestX,
     int iDestY,
     int sourceX1, int sourceY1, int sourceX2, int sourceY2,
     int targetR, int targetG, int targetB, int keyCol);
コード例 #2
0
ファイル: Surface.cs プロジェクト: hayate891/freetrain
 public void Dispose()
 {
     // explicitly release a reference
     if (surface != null)
     {
         System.Runtime.InteropServices.Marshal.ReleaseComObject(surface);
     }
     surface = null;
 }
コード例 #3
0
ファイル: Surface.cs プロジェクト: hayate891/freetrain
        internal Surface(DirectDrawSurface7 _handle)
        {
            this.surface = _handle;

            // compute the size of this surface
            DDSURFACEDESC2 desc = new DDSURFACEDESC2();

            surface.GetSurfaceDesc(ref desc);
            this.size = new Size(desc.lWidth, desc.lHeight);
            resetClipRect();

            // compute the bit shift width for color fill
            DDPIXELFORMAT pixelFormat = new DDPIXELFORMAT();

            surface.GetPixelFormat(ref pixelFormat);
            widthR = countBitWidth(pixelFormat.lRBitMask);
            widthG = countBitWidth(pixelFormat.lGBitMask);
            widthB = countBitWidth(pixelFormat.lBBitMask);
        }
コード例 #4
0
 /// <summary>
 ///  Helper function used to complete initialization of a surface.
 /// </summary>
 private void CreateSurface()
 {
     #if TRACE
     ManagedDirectX.Profiler.Start("CreateSurface");
     #endif
     try
     {
         if (string.IsNullOrEmpty(image))
         {
             surface = ManagedDirectX.DirectDraw.CreateSurface(ref descriptor);
             if (surface != null)
             {
                 rect.Bottom = descriptor.lHeight;
                 rect.Right = descriptor.lWidth;
             }
         }
         else
         {
             try
             {
                 Trace.WriteLine(image);
                 try
                 {
                     surface = ManagedDirectX.DirectDraw.CreateSurfaceFromFile(image, ref descriptor);
                 }
                 catch (ArgumentException)
                 {
                     descriptor = SystemMemorySurfaceDescription;
                     surface = ManagedDirectX.DirectDraw.CreateSurfaceFromFile(image, ref descriptor);
                 }
             }
             catch (COMException e)
             {
                 // File Not Found
                 switch ((uint) e.ErrorCode)
                 {
                     case 0x800A0035:
                         Trace.WriteLine(
                             "Could not find the file '" + image +
                             "'.  This must be placed in the current directory.", "Picture Not Found");
                         break;
                     case 0x8876024E:
                         Trace.WriteLine(
                             "The graphics card is in an unsupported mode.  We will try to initalize again later.");
                         throw new DirectXException(
                             "Error Creating a DirectDraw Surface because of unsupported graphics mode.", e);
                     default:
                         Trace.WriteLine("Unexpected exception: " + e, "Unexpected Exception");
                         break;
                 }
             }
             rect.Bottom = descriptor.lHeight;
             rect.Right = descriptor.lWidth;
         }
     }
     catch (Exception exc)
     {
         throw new DirectXException("Error Creating a DirectDraw Surface", exc);
     }
     #if TRACE
     ManagedDirectX.Profiler.End("DirectDrawSurface.CreateSurface");
     #endif
 }
コード例 #5
0
 /// <summary>
 ///  Initialize a new surface based on a previously created surface
 /// </summary>
 /// <param name="directDrawSurface">The native DirectDraw surface used as reference.</param>
 public DirectDrawSurface(DirectDrawSurface7 directDrawSurface)
 {
     directDrawSurface.GetSurfaceDesc(ref descriptor);
     surface = directDrawSurface;
 }
コード例 #6
0
        /// <summary>
        ///  Helper function used to complete initialization of a surface.
        /// </summary>
        private void CreateSurface()
        {
#if TRACE
            GraphicsEngine.Profiler.Start("CreateSurface");
#endif
            try
            {
                if (string.IsNullOrEmpty(_image))
                {
                    _surface = ((DirectX7GraphicsEngine)(GraphicsEngine.Current)).DirectDraw.CreateSurface(ref _descriptor);
                    if (_surface != null)
                    {
                        _rect.Bottom = _descriptor.lHeight;
                        _rect.Right  = _descriptor.lWidth;
                    }
                }
                else
                {
                    try
                    {
                        Trace.WriteLine(_image);
                        try
                        {
                            _surface = ((DirectX7GraphicsEngine)(GraphicsEngine.Current)).DirectDraw.CreateSurfaceFromFile(_image, ref _descriptor);
                        }
                        catch (ArgumentException)
                        {
                            _descriptor = SystemMemorySurfaceDescription;
                            _surface    = ((DirectX7GraphicsEngine)(GraphicsEngine.Current)).DirectDraw.CreateSurfaceFromFile(_image, ref _descriptor);
                        }
                    }
                    catch (COMException e)
                    {
                        // File Not Found
                        switch ((uint)e.ErrorCode)
                        {
                        case 0x800A0035:
                            Trace.WriteLine(
                                "Could not find the file '" + _image +
                                "'.  This must be placed in the current directory.", "Picture Not Found");
                            break;

                        case 0x8876024E:
                            Trace.WriteLine(
                                "The graphics card is in an unsupported mode.  We will try to initalize again later.");
                            throw new GraphicsException(
                                      "Error Creating a DirectDraw Surface because of unsupported graphics mode.", e);

                        default:
                            Trace.WriteLine("Unexpected exception: " + e, "Unexpected Exception");
                            break;
                        }
                    }
                    _rect.Bottom = _descriptor.lHeight;
                    _rect.Right  = _descriptor.lWidth;
                }
            }
            catch (Exception exc)
            {
                throw new GraphicsException("Error Creating a DirectDraw Surface", exc);
            }
#if TRACE
            GraphicsEngine.Profiler.End("DirectDrawSurface.CreateSurface");
#endif
        }
コード例 #7
0
 /// <summary>
 ///  Initialize a new surface based on a previously created surface
 /// </summary>
 /// <param name="directDrawSurface">The native DirectDraw surface used as reference.</param>
 internal DirectDrawSurface(DirectDrawSurface7 directDrawSurface)
 {
     directDrawSurface.GetSurfaceDesc(ref _descriptor);
     _surface = directDrawSurface;
 }
コード例 #8
0
 /// <summary>
 ///  Initialize a new surface based on a previously created surface
 /// </summary>
 /// <param name="directDrawSurface">The native DirectDraw surface used as reference.</param>
 public DirectDrawSurface(DirectDrawSurface7 directDrawSurface)
 {
     directDrawSurface.GetSurfaceDesc(ref descriptor);
     surface = directDrawSurface;
 }