• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Byte4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Byte4的典型用法代码示例。如果您正苦于以下问题:C# Byte4类的具体用法?C# Byte4怎么用?C# Byte4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Byte4类属于命名空间,在下文中一共展示了Byte4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetDiamond

        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 返回一个菱形Texture2D
        /// </summary>
        public static Texture2D GetDiamond(int width, int height, Color color, Game game)
        {
            Texture2D ttDmd = new Texture2D(game.GraphicsDevice, width, height);
            Byte4[] btDmd = new Byte4[width * height];
            Vector2 vtO = new Vector2(width / 2f, height / 2f);
            // Point ptPos = new Point(i / ttRound.Width, i % ttRound.Width);
            // ptPos.X = Row number, ptPos.Y = Col number
            for (int x = 0; x <= width / 2; x++)
            {
                for (int y = 0; y <= height / 2; y++)
                {
                    if (width / 2f * y + height / 2f * x >= width * height / 4f)
                    {
                        uint packed = (uint)(
                                (color.A << 24) +
                                (color.B << 16) +
                                (color.G << 8) +
                                color.R
                                );
                        btDmd[Vector2ToIndex(new Vector2(x, y), width)].PackedValue = packed;
                        if (x != 0)
                            btDmd[Vector2ToIndex(new Vector2(width - x, y), width)].PackedValue = packed;
                        if (y != 0)
                            btDmd[Vector2ToIndex(new Vector2(x, height - y), width)].PackedValue = packed;
                        if (x != 0 && y != 0)
                            btDmd[Vector2ToIndex(new Vector2(width - x, height - y), width)].PackedValue = packed;
                    }
                }
            }
            ttDmd.SetData<Byte4>(btDmd);

            return ttDmd;
        }
开发者ID:TiaraGames,项目名称:TiaraFramework,代码行数:37,代码来源:Shape.cs


示例2: processTexture

        private Texture2D processTexture(Texture2D texture)
        {
            //Some programs such as Photoshop save PNG and other RGBA images without premultiplied alpha
            if (!Constants.Instance.PremultipliedAlpha)
            {

                //XNA 4.0+ assumes that all RGBA images have premultiplied alpha channels.
                //Code snippet borrowed from http://xboxforums.create.msdn.com/forums/p/62320/383015.aspx#485897

                Byte4[] data = new Byte4[texture.Width * texture.Height];
                texture.GetData<Byte4>(data);
                for (int i = 0; i < data.Length; i++)
                {
                    Vector4 vec = data[i].ToVector4();
                    float alpha = vec.W / 255.0f;
                    int a = (int)(vec.W);
                    int r = (int)(alpha * vec.X);
                    int g = (int)(alpha * vec.Y);
                    int b = (int)(alpha * vec.Z);
                    uint packed = (uint)(
                        (a << 24) +
                        (b << 16) +
                        (g << 8) +
                        r
                        );

                    data[i].PackedValue = packed;
                }

                texture.SetData<Byte4>(data);
            }

            return texture;
        }
开发者ID:WinterGroveProductions,项目名称:Gleed2D,代码行数:34,代码来源:TextureStore.cs


示例3: PackNormalB4

 static public Byte4 PackNormalB4(ref Vector3 normal)
 {
     uint packedValue = PackNormal(ref normal);
     Byte4 b4 = new Byte4();
     b4.PackedValue = packedValue;
     return b4;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:VF_Packer.cs


示例4: AddSprite

 internal void AddSprite(Vector2 clipOffset, Vector2 clipScale, Vector2 texOffset, Vector2 texScale, Byte4 color)
 {
     MySpritesRenderer.m_spriteInstanceList.Add(new MyVertexFormatSpritePositionTextureColor(
         new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
         new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
         color));
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MySpritesRenderer.cs


示例5: AddSprite

 internal void AddSprite(Vector2 clipOffset, Vector2 clipScale, Vector2 texOffset, Vector2 texScale, 
     Vector2 origin, Vector2 tangent, Byte4 color)
 {
     MySpritesRenderer.StackTop().m_instances.Add(new MyVertexFormatSpritePositionTextureRotationColor(
         new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
         new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
         new HalfVector4(origin.X, origin.Y, tangent.X, tangent.Y),
         color));
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:9,代码来源:MySpritesRenderer.cs


示例6: VertexPositionNormalBlendable

 /// <summary>
 /// Initializes a new instance of the <see cref="VertexPositionNormalBlendable"/> struct.
 /// </summary>
 /// <param name="position">
 /// The position of the vertex.
 /// </param>
 /// <param name="normal">
 /// The normal of the vertex.
 /// </param>
 /// <param name="boneWeight">
 /// The bone weightings that apply to the vertex.
 /// </param>
 /// <param name="boneIndices">
 /// The bone IDs that apply to the vertex.
 /// </param>
 public VertexPositionNormalBlendable(
     Vector3 position, 
     Vector3 normal,
     Vector4 boneWeight, 
     Byte4 boneIndices)
 {
     this.Position = position;
     this.Normal = normal;
     this.BoneWeights = boneWeight;
     this.BoneIndices = boneIndices;
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:26,代码来源:VertexPositionNormalBlendable.cs


示例7: InstancedVertexPositionNormalTextureBumpSkin

        public InstancedVertexPositionNormalTextureBumpSkin(VertexPositionNormalTextureBumpSkin source, Matrix meshToObject, byte index)
        {
            Position = source.Position;
            Normal = source.Normal;
            TextureCoordinate1 = source.TextureCoordinate;
            TextureCoordinate2 = source.TextureCoordinate;
            Tangent = source.Tangent;
            Binormal = source.Binormal;

            BoneIndices = new Byte4(source.BoneIndex0, source.BoneIndex1, source.BoneIndex2, source.BoneIndex3);
            BoneWeights = source.BoneWeights;     
        }
开发者ID:Indiefreaks,项目名称:igf,代码行数:12,代码来源:InstancedVertexPositionTextureBumpSkin.cs


示例8: AddQuad

        internal void AddQuad(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
        {
            var bcolor = new Byte4(color.R, color.G, color.B, color.A);

            Add(new MyVertexFormatPositionColor(v0, bcolor));
            Add(new MyVertexFormatPositionColor(v1, bcolor));

            Add(new MyVertexFormatPositionColor(v1, bcolor));
            Add(new MyVertexFormatPositionColor(v2, bcolor));

            Add(new MyVertexFormatPositionColor(v2, bcolor));
            Add(new MyVertexFormatPositionColor(v3, bcolor));

            Add(new MyVertexFormatPositionColor(v3, bcolor));
            Add(new MyVertexFormatPositionColor(v0, bcolor));
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:16,代码来源:MyLinesRenderer.cs


示例9: MultiplyAlpha

        private static void MultiplyAlpha(Texture2D ret)
        {
            var data = new Byte4[ret.Width*ret.Height];

            ret.GetData(data);
            for (int i = 0; i < data.Length; i++)
            {
                Vector4 vec = data[i].ToVector4();
                float alpha = vec.W/255.0f;
                var a = (int) (vec.W);
                var r = (int) (alpha*vec.X);
                var g = (int) (alpha*vec.Y);
                var b = (int) (alpha*vec.Z);
                var packed = (uint) ((a << 24) + (b << 16) + (g << 8) + r);

                data[i].PackedValue = packed;
            }

            ret.SetData(data);
        }
开发者ID:xupefei,项目名称:EAGSS,代码行数:20,代码来源:APNGFrame.cs


示例10: AddBoundingBox

        internal void AddBoundingBox(BoundingBox bb, Color color)
        {
            var v0 = bb.Center - bb.HalfExtents;
            var v1 = v0 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
            var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
            var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);

            var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
            var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
            var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
            var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);

            var bcolor = new Byte4(color.R, color.G, color.B, color.A);

            Add(new MyVertexFormatPositionColor(v0, bcolor));
            Add(new MyVertexFormatPositionColor(v1, bcolor));
            Add(new MyVertexFormatPositionColor(v1, bcolor));
            Add(new MyVertexFormatPositionColor(v2, bcolor));
            Add(new MyVertexFormatPositionColor(v2, bcolor));
            Add(new MyVertexFormatPositionColor(v3, bcolor));
            Add(new MyVertexFormatPositionColor(v0, bcolor));
            Add(new MyVertexFormatPositionColor(v3, bcolor));

            Add(new MyVertexFormatPositionColor(v4, bcolor));
            Add(new MyVertexFormatPositionColor(v5, bcolor));
            Add(new MyVertexFormatPositionColor(v5, bcolor));
            Add(new MyVertexFormatPositionColor(v6, bcolor));
            Add(new MyVertexFormatPositionColor(v6, bcolor));
            Add(new MyVertexFormatPositionColor(v7, bcolor));
            Add(new MyVertexFormatPositionColor(v4, bcolor));
            Add(new MyVertexFormatPositionColor(v7, bcolor));

            Add(new MyVertexFormatPositionColor(v0, bcolor));
            Add(new MyVertexFormatPositionColor(v4, bcolor));
            Add(new MyVertexFormatPositionColor(v1, bcolor));
            Add(new MyVertexFormatPositionColor(v5, bcolor));
            Add(new MyVertexFormatPositionColor(v2, bcolor));
            Add(new MyVertexFormatPositionColor(v6, bcolor));
            Add(new MyVertexFormatPositionColor(v3, bcolor));
            Add(new MyVertexFormatPositionColor(v7, bcolor));
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:41,代码来源:MyLinesRenderer.cs


示例11: ModelVertex

 public ModelVertex(
     Vector3? position,
     Vector3? normal,
     Vector3? tangent,
     Vector3? bitangent,
     Color[] colors,
     Vector2[] texCoordsUV,
     Vector3[] texCoordsUVW,
     Byte4? boneIndicies,
     Vector4? boneWeights)
 {
     Position = position;
     Normal = normal;
     Tangent = tangent;
     BiTangent = bitangent;
     Colors = colors;
     TexCoordsUV = texCoordsUV;
     TexCoordsUVW = texCoordsUVW;
     BoneIndices = boneIndicies;
     BoneWeights = boneWeights;
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:21,代码来源:ModelVertex.cs


示例12: PreMultiplyAlphas

 // by 火必烈
 public static void PreMultiplyAlphas(Texture2D ret)
 {
     Byte4[] data = new Byte4[ret.Width * ret.Height];
     ret.GetData<Byte4>(data);
     for (int i = 0; i < data.Length; i++)
     {
         Vector4 vec = data[i].ToVector4();
         float alpha = vec.W / 255.0f;
         int a = (int)(vec.W);
         int r = (int)(alpha * vec.X);
         int g = (int)(alpha * vec.Y);
         int b = (int)(alpha * vec.Z);
         uint packed = (uint)(
             (a << 24) +
             (b << 16) +
             (g << 8) +
             r
             );
         data[i].PackedValue = packed;
     }
     ret.SetData<Byte4>(data);
 }
开发者ID:TiaraGames,项目名称:TiaraFramework,代码行数:23,代码来源:Underlying.cs


示例13: MyVertexFormatNormal

 internal MyVertexFormatNormal(Byte4 normal, Byte4 normalMorph)
 {
     Normal = normal;
     NormalMorph = normalMorph;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例14: MyVertexFormatTexcoordNormalTangentTexindices

 internal MyVertexFormatTexcoordNormalTangentTexindices(Vector2 texcoord, Vector3 normal, Vector3 tangent, Byte4 texIndices)
 {
     Texcoord = new HalfVector2(texcoord.X, texcoord.Y);
     Normal = VF_Packer.PackNormalB4(ref normal);
     Vector4 T = new Vector4(tangent, 1);
     Tangent = VF_Packer.PackTangentSignB4(ref T);
     TexIndices = texIndices;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:MyVertexFormats.cs


示例15: MyVertexFormatTexcoordNormalTangent

 internal MyVertexFormatTexcoordNormalTangent(HalfVector2 texcoord, Byte4 normal, Byte4 tangent)
 {
     Texcoord = texcoord;
     Normal = normal;
     Tangent = tangent;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:6,代码来源:MyVertexFormats.cs


示例16: TestMemberFn_GetHashCode_i

 public void TestMemberFn_GetHashCode_i ()
 {
     HashSet<Int32> hs = new HashSet<Int32>();
     var rand = new System.Random();
     var buff = new Byte[4];
     UInt32 collisions = 0;
     for(Int32 i = 0; i < Settings.NumTests; ++i)
     {
         rand.NextBytes(buff);
         BitConverter.ToUInt32(buff, 0);
         UInt32 packed = BitConverter.ToUInt32(buff, 0);
         var packedObj = new Byte4();
         packedObj.PackedValue = packed;
         Int32 hc = packedObj.GetHashCode ();
         if(hs.Contains(hc)) ++collisions;
         hs.Add(hc);
     }
     Assert.That(collisions, Is.LessThan(10));
 }
开发者ID:gitter-badger,项目名称:blimey,代码行数:19,代码来源:Fudge.Tests.cs


示例17: MyVertexFormatPositionColor

 internal MyVertexFormatPositionColor(Vector3 position, Color color)
 {
     Position = position;
     Color = new Byte4(color.PackedValue);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例18: MyVertexFormatPositionPackedColor

 internal MyVertexFormatPositionPackedColor(Vector3 position, Color color)
 {
     Position = new HalfVector4(position.X, position.Y, position.Z, 1);
     Color = new Byte4(color.PackedValue);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例19: MyVertexFormatPositionSkinning

 internal MyVertexFormatPositionSkinning(HalfVector4 position, Byte4 indices, Vector4 weights)
 {
     Position = position;
     BoneIndices = indices;
     BoneWeights = new HalfVector4(weights);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:6,代码来源:MyVertexFormats.cs


示例20: ExportDataPackedAsB4

        public bool ExportDataPackedAsB4(string tagName, Vector3[] vctArr)
        {
            WriteTag(tagName);

            if (vctArr == null)
            {
                m_writer.Write(0);
                return true;
            }

            m_writer.Write(vctArr.Length);
            foreach (Vector3 vctVal in vctArr)
            {
                Vector3 v = vctVal;
                Byte4 vct = new Byte4();
                vct.PackedValue = VF_Packer.PackNormal(ref v);
                WriteByte4(vct);
            }

            return true;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:21,代码来源:MyModelExporter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ByteArray类代码示例发布时间:2022-05-24
下一篇:
C# Byte类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap