本文整理汇总了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);
}
示例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 } });
}
示例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;
}
示例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;
}
示例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);
}
示例6: SetColor
public void SetColor(Color[] iColors)
{
_colors = new Color[iColors.Length];
iColors.CopyTo(_colors, 0);
Apply();
}
示例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);
}