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


C# Byte4类代码示例

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


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


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