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


C# Color.CopyTo方法代码示例

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


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

示例1: RagePixelBitmap

 public RagePixelBitmap(Color[] _pixels, int width, int height)
 {
     W = width;
     H = height;
     pixels = new Color[_pixels.Length];
     _pixels.CopyTo(pixels, 0);
 }
开发者ID:B1sounours,项目名称:RagePixel,代码行数:7,代码来源:RagePixelBitmap.cs

示例2: DrawColors

        public virtual void DrawColors(Color[] colors, Vector2 size, Vector2 location)
        {
            if (colors == null) throw new ArgumentNullException("colors");

            Color[] copiedColors = new Color[colors.Length];
            colors.CopyTo(copiedColors, 0);
            this._commands.Enqueue(new ContextCommand { CommandType = CommandType.DrawColors, Vectors = new Vector2[] { size, location }, Addtions = new object[] { copiedColors } });
        }
开发者ID:mind0n,项目名称:hive,代码行数:8,代码来源:DrawingContext.cs

示例3: mbAddToRenderBuffer

    public void mbAddToRenderBuffer(ref Vector3[] vertices, ref Vector2[] uvs, ref Color[] colors)
    {
        if (mBufferPtr == mVertices.Length)
            mbEnlargeBuffers(LayerBlocksize);

        vertices.CopyTo(mVertices, mBufferPtr);
        uvs.CopyTo(mUVs, mBufferPtr);
        colors.CopyTo(mColors, mBufferPtr);

        int i = (mBufferPtr / 4) * 6;
        mTriangles[i++] = mBufferPtr;
        mTriangles[i++] = mBufferPtr + 1;
        mTriangles[i++] = mBufferPtr + 2;
        mTriangles[i++] = mBufferPtr + 2;
        mTriangles[i++] = mBufferPtr + 3;
        mTriangles[i++] = mBufferPtr;

        mBufferPtr += 4;
    }
开发者ID:rstaewen,项目名称:Pharos,代码行数:19,代码来源:MBLayer.cs

示例4: GetFrameBuffer

        public Bitmap GetFrameBuffer( )
        {
            ushort widthInWords;
            ushort heightInPixels;
            uint[ ] buf;

            Bitmap bmp = null;


            PixelFormat pixelFormat = PixelFormat.DontCare;

            if( GetFrameBuffer( out widthInWords, out heightInPixels, out buf ) )
            {
                CLRCapabilities.LCDCapabilities lcdCaps = Capabilities.LCD;

                int pixelsPerWord = 32 / ( int )lcdCaps.BitsPerPixel;

                Debug.Assert( heightInPixels == lcdCaps.Height );
                Debug.Assert( widthInWords == ( lcdCaps.Width + pixelsPerWord - 1 ) / pixelsPerWord );

                Color[ ] colors = null;

                switch( lcdCaps.BitsPerPixel )
                {
                case 1:
                    pixelFormat = PixelFormat.Format1bppIndexed;
                    colors = new Color[ ] { Color.White, Color.Black };
                    Adjust1bppOrientation( buf );
                    break;
                case 4:
                case 8:
                    //Not tested
                    int cColors = 1 << ( int )lcdCaps.BitsPerPixel;

                    pixelFormat = ( lcdCaps.BitsPerPixel == 4 ) ? PixelFormat.Format4bppIndexed : PixelFormat.Format8bppIndexed;

                    colors = new Color[ cColors ];

                    for( int i = 0; i < cColors; i++ )
                    {
                        int intensity = 256 / cColors * i;
                        colors[ i ] = Color.FromArgb( intensity, intensity, intensity );
                    }

                    break;
                case 16:
                    pixelFormat = PixelFormat.Format16bppRgb565;
                    break;
                default:
                    Debug.Assert( false );
                    return null;
                }

                BitmapData bitmapData = null;

                try
                {
                    bmp = new Bitmap( ( int )lcdCaps.Width, ( int )lcdCaps.Height, pixelFormat );
                    Rectangle rect = new Rectangle( 0, 0, ( int )lcdCaps.Width, ( int )lcdCaps.Height );

                    if( colors != null )
                    {
                        ColorPalette palette = bmp.Palette;
                        colors.CopyTo( palette.Entries, 0 );
                        bmp.Palette = palette;
                    }

                    bitmapData = bmp.LockBits( rect, ImageLockMode.WriteOnly, pixelFormat );
                    IntPtr data = bitmapData.Scan0;

                    unsafe
                    {
                        fixed( uint* pbuf = buf )
                        {
                            uint* src = ( uint* )pbuf;
                            uint* dst = ( uint* )data.ToPointer( );

                            for( int i = buf.Length; i > 0; i-- )
                            {
                                *dst = *src;
                                dst++;
                                src++;
                            }

                        }
                    }
                }

                finally
                {
                    if( bitmapData != null )
                    {
                        bmp.UnlockBits( bitmapData );
                    }
                }
            }

            return bmp;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:99,代码来源:Engine.cs

示例5: SetForcedStateVerts

		void SetForcedStateVerts(Vector3[] verts, Color[] cols)
		{
			if(m_forced_state_verts == null || m_forced_state_verts.Length != verts.Length)
				m_forced_state_verts = new Vector3[verts.Length];
			verts.CopyTo(m_forced_state_verts, 0);

			if(m_forced_state_cols == null || m_forced_state_cols.Length != cols.Length)
				m_forced_state_cols = new Color[cols.Length];
			cols.CopyTo(m_forced_state_cols, 0);

		}
开发者ID:DarkRay,项目名称:neverending-story,代码行数:11,代码来源:TextFxNative.cs

示例6: SetColor

 public void SetColor(Color[] iColors)
 {
     _colors = new Color[iColors.Length];
       iColors.CopyTo(_colors, 0);
       Apply();
 }
开发者ID:SinSiXX,项目名称:VertexPaint,代码行数:6,代码来源:VertexInstanceStream.cs

示例7: SeperateRGBAandlphaChannel

    static void SeperateRGBAandlphaChannel(string _texPath)
    {
        string assetRelativePath = GetRelativeAssetPath(_texPath);
        SetTextureReadableEx(assetRelativePath);    //set readable flag and set textureFormat TrueColor
        Texture2D sourcetex = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(Texture2D)) as Texture2D; //not just the textures under Resources file
        if (!sourcetex)
        {
            Debug.LogError("Load Texture Failed : " + assetRelativePath);
            return;
        }

        TextureImporter ti = null;
        try
        {
            ti = (TextureImporter)TextureImporter.GetAtPath(assetRelativePath);
        }
        catch
        {
            Debug.LogError("Load Texture failed: " + assetRelativePath);
            return;
        }

        if (ti == null)
        {
            return;
        }

        bool bGenerateMipMap = ti.mipmapEnabled;    //same with the texture import setting

        Texture2D rgbTex = new Texture2D(sourcetex.width, sourcetex.height, TextureFormat.RGB24, bGenerateMipMap);
        rgbTex.SetPixels(sourcetex.GetPixels());

        Texture2D mipMapTex = new Texture2D(sourcetex.width, sourcetex.height, TextureFormat.RGBA32, true);  //Alpha Channel needed here
        mipMapTex.SetPixels(sourcetex.GetPixels());
        mipMapTex.Apply();

        Color[] colors2rdLevel = mipMapTex.GetPixels(0);   //Second level of Mipmap
        Color[] colorsAlpha = new Color[colors2rdLevel.Length];

        //if (colors2rdLevel.Length != (mipMapTex.width + 1) / 2 * (mipMapTex.height + 1) / 2)
        //{
        if (colors2rdLevel.Length != mipMapTex.width * mipMapTex.height)
        {
            Debug.LogError("Size Error.");
            return;
        }

        bool bAlphaExist = false;

        for (int i = 0; i < colors2rdLevel.Length; ++i)
        {
            colorsAlpha[i].r = colors2rdLevel[i].a;
            colorsAlpha[i].g = colors2rdLevel[i].a;
            colorsAlpha[i].b = colors2rdLevel[i].a;

            if (!Mathf.Approximately(colors2rdLevel[i].a, 1.0f))
            {
                bAlphaExist = true;
            }
        }

        Texture2D alphaTex = null;

        if (bAlphaExist)
        {
            alphaTex = new Texture2D(sourcetex.width, sourcetex.height * 2, TextureFormat.RGB24, bGenerateMipMap);
        }
        else
        {
            alphaTex = new Texture2D(defaultWhiteTex.width, defaultWhiteTex.height, TextureFormat.RGB24, false);
        }

        Color[] colorsRGBA = new Color[colors2rdLevel.Length + colorsAlpha.Length];
        colors2rdLevel.CopyTo(colorsRGBA, 0);
        colorsAlpha.CopyTo(colorsRGBA, colors2rdLevel.Length);

        alphaTex.SetPixels(colorsRGBA);

        rgbTex.Apply();
        alphaTex.Apply();

        byte[] bytes = rgbTex.EncodeToPNG();
        File.WriteAllBytes(assetRelativePath, bytes);
        byte[] alphabytes = alphaTex.EncodeToPNG();
        string alphaTexRelativePath = GetAlphaTexPath(_texPath);
        File.WriteAllBytes(alphaTexRelativePath, alphabytes);

        ReImportAsset(assetRelativePath, rgbTex.width, rgbTex.height);
        ReImportAsset(alphaTexRelativePath, alphaTex.width, alphaTex.height);
        Debug.Log("Succeed Departing : " + assetRelativePath);
    }
开发者ID:yangruihan,项目名称:Unity3D_Project,代码行数:91,代码来源:MaterialTextureForETC1OnePicture.cs


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