当前位置: 首页>>代码示例>>C#>>正文


C# ISurface.GetSurface方法代码示例

本文整理汇总了C#中ISurface.GetSurface方法的典型用法代码示例。如果您正苦于以下问题:C# ISurface.GetSurface方法的具体用法?C# ISurface.GetSurface怎么用?C# ISurface.GetSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISurface的用法示例。


在下文中一共展示了ISurface.GetSurface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertLandSurface

        private static unsafe void ConvertLandSurface(ISurface surface, out byte[] rawdata)
        {
            if (surface.Stride / surface.Width != 2)
                throw new NotImplementedException();

            var bitmap = surface.GetSurface();// as BitmapSurface;
            var imrect = bitmap.GetImageRect();
            var imavrx = bitmap.Width / 2;
            var imlenx = Math.Min(Math.Max(imavrx - imrect.X1, imrect.X2 + 1 - imavrx), imavrx);
            imrect = new Clipper2D((short)(imavrx - imlenx), imrect.Y1, (short)(imavrx + imlenx - 1), (short)(bitmap.Height - 1));

            if (imrect.Width != 44 || imrect.Height != 44) {
                imrect = new Clipper2D((short)0, (short)0, (ushort)bitmap.Width, (ushort)bitmap.Height);
                if (imrect.Width != 44 || imrect.Height != 44)
                    throw new ClassicFactoryException();
            }

            rawdata = new byte[0x07E8];
            lock (surface) {
                uint    delta = surface.Stride >> 1;
                ushort* line1 = surface.ImageWordPtr + imrect.Y1 * delta + imrect.X1;
                ushort* line2 = surface.ImageWordPtr + imrect.Y2 * delta + imrect.X1;  

                fixed (byte* _data = &rawdata[0]) {
                    var data = (uint*)_data;

                    //data[0] = 0x00000000; // header
                    var i1 = 0;
                    var i2 = 505;
                    for (var y = 0; y < 22; ++y, line1 += delta, line2 -= delta) {
                        var cur1 = (uint*)(line1 + 21 - y);
                        var cur2 = (uint*)(line2 + 21 + y);
                        for (var x = 0; x <= y; ++x, ++i1, --i2, ++cur1, --cur2) {
                            data[i1] = *cur1 ^ 0x80008000;
                            data[i2] = *cur2 ^ 0x80008000;
                        }
                    }
                }
            }
        }
开发者ID:svn2github,项目名称:essence-udk,代码行数:40,代码来源:ClassicFactory.cs

示例2: ConvertItemSurface

        private static unsafe void ConvertItemSurface(ISurface surface, out byte[] rawdata)
        {
            if (surface.Stride / surface.Width != 2)
                throw new NotImplementedException();

            var bitmap = surface.GetSurface();// as BitmapSurface;
            var imrect = bitmap.GetImageRect();
            var imavrx = bitmap.Width / 2;
            var imlenx = Math.Min(Math.Max(imavrx - imrect.X1, imrect.X2 + 1 - imavrx), imavrx);
            imrect = new Clipper2D((short)(imavrx - imlenx), imrect.Y1, (short)(imavrx + imlenx - 1), (short)(bitmap.Height - 1));

            var data = new BinaryWriter(new MemoryStream());
            data.Write((uint)1234); // header
            data.Write((ushort)imrect.Width);
            data.Write((ushort)imrect.Height);

            var lookup = (int)data.BaseStream.Position;
            for (var y = 0; y < imrect.Height; ++y)// fill lookup
                data.Write((ushort)0);
  
            lock (surface) {
                uint   delta = surface.Stride >> 1;
                ushort* line = surface.ImageWordPtr + imrect.Y1 * delta;               

                for (int y = 0; y < imrect.Height; ++y, line += delta) {

                    data.BaseStream.Seek(lookup + (y << 1), SeekOrigin.Begin);
                    var lineoffs = ((data.BaseStream.Length - lookup) >> 1) - imrect.Height;
                    if (lineoffs > 0xFFFF)
                        throw new ClassicFactoryException();
                    data.Write( (ushort)lineoffs );
                    data.BaseStream.Seek(0, SeekOrigin.End);

                    ushort* cur = line + imrect.X1;
                    int x = 0, j = 0, i = 0;

                    while (i < imrect.Width) {
                        for (i = x; i < imrect.Width; ++i) {
                            //first pixel set
                            if (cur[i] != 0)
                                break;
                        }
                        if (i < imrect.Width) {
                            for (j = (i + 1); j < imrect.Width; ++j) {
                                //next non set pixel
                                // if (cur[j] == 0)
                                if (cur[j] == 0 && (j + 1 == imrect.Width || cur[j + 1] == 0))
                                    break;
                            }
                            data.Write((ushort)(i - x)); //xoffset
                            data.Write((ushort)(j - i)); //run
                            for (int p = i; p < j; ++p)
                                //data.Write((ushort)(cur[p] ^ 0x8000);
                                data.Write((ushort)(cur[p] > 0 ? (cur[p] ^ 0x8000) : cur[p]));
                            x = j;
                        }
                    }
                    data.Write((ushort)0); //xOffset
                    data.Write((ushort)0); //Run
                }
            }

            data.Flush();
            rawdata = (data.BaseStream as MemoryStream).ToArray();
            data.Close();
        }
开发者ID:svn2github,项目名称:essence-udk,代码行数:66,代码来源:ClassicFactory.cs

示例3: Render

        private void Render(int cmd)
        {
            if (UOManager == null) {
                MessageBox.Show("Enter client path and load client mul files to be able to draw facet.");
                return;
            }

            var flt = cmd < 20;
            //if (flt)
            //    cmd -= 10;
            //else
            //    cmd -= 20;
            var _cmdlast = flt ? 10 : 20;
            if (cmdlast != _cmdlast ) {
                avrg_ticks = avrg_draws = 0;
                cmdlast = _cmdlast ;
            }

            switch (cmd) {
                case 17: goto case 28;
                case 13: goto case 22;
                case 19: goto case 26;
                case 11: goto case 24;
                case 18: goto case 29;
                case 12: goto case 21;
                case 14: goto case 27;
                case 16: goto case 23;
                case 27: nudX.Value -= 1; break;
                case 23: nudX.Value += 1; break;
                case 29: nudY.Value -= 1; break;
                case 21: nudY.Value += 1; break;
                case 28: nudX.Value -= 1; nudY.Value -= 1; break;
                case 22: nudX.Value += 1; nudY.Value += 1; break;
                case 24: nudX.Value -= 1; nudY.Value += 1; break;
                case 26: nudX.Value += 1; nudY.Value -= 1; break;
                default: break;
            }

            if (nudX.Value < nudX.Minimum)
                nudX.Value = nudX.Minimum;
            if (nudY.Value < nudY.Minimum)
                nudY.Value = nudY.Minimum;
            if (nudX.Value > nudX.Maximum)
                nudX.Value = nudX.Maximum;
            if (nudY.Value > nudY.Maximum)
                nudY.Value = nudY.Maximum;

            var surw = (ushort)nudW.Value;
            var surh = (ushort)nudH.Value;
            var map = (byte)nudM.Value;
            var range = (byte)nudR.Value;
            var tcx = (ushort)nudX.Value;
            var tcy = (ushort)nudY.Value;
            var minz = (sbyte)nudMinZ.Value;
            var maxz = (sbyte)nudMaxZ.Value;
            var alt = (short)nudS.Value;

            


            surf = UOManager.CreateSurface(surw, surh, PixelFormat.Bpp16X1R5G5B5);
            var ticks = Environment.TickCount;
            if (flt)
                UOManager.FacetRender.DrawFlatMap(map, alt, ref surf, range, tcx, tcy, minz, maxz);
            else
                UOManager.FacetRender.DrawObliqueMap(map, alt, ref surf, range, tcx, tcy, minz, maxz);

            var take_ticks = Environment.TickCount - ticks;
            avrg_ticks += take_ticks;
            ++avrg_draws;
            lblStatus.Content = String.Format("Draw in: {0:00000} ms / Avrg: {1:00000}ms", take_ticks, avrg_ticks / avrg_draws);

            //var bid = UOManager.GetMapFacet(map).GetBlockId((uint)nudX.Value, (uint)nudY.Value);
            //UOManager.FacetRender.DrawBlock(ref surf, map, bid);
            imgFacet.Source = surf.GetSurface().Image;
        }
开发者ID:svn2github,项目名称:essence-udk,代码行数:76,代码来源:MainWindow.xaml.cs


注:本文中的ISurface.GetSurface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。