本文整理汇总了C#中SdlDotNet.Graphics.Surface.SetPixels方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.SetPixels方法的具体用法?C# Surface.SetPixels怎么用?C# Surface.SetPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdlDotNet.Graphics.Surface
的用法示例。
在下文中一共展示了Surface.SetPixels方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSurfaces
public static SurfaceCollection LoadSurfaces(string resourceName, Size tileSize)
{
SurfaceCollection ret = new SurfaceCollection();
ret.AlphaBlending = true;
using (Surface s = LoadSurface(resourceName))
{
for (int i = 0; i < s.Width; i += tileSize.Width)
{
for (int j = 0; j < s.Height; j += tileSize.Height)
{
Surface ss = new Surface(tileSize.Width, tileSize.Height, 32, s.RedMask, s.GreenMask, s.BlueMask, s.AlphaMask);
ss.Transparent = true;
ss.AlphaBlending = true;
Color[,] tmp = s.GetColors(new Rectangle(i, j, tileSize.Width, tileSize.Height));
ss.SetPixels(Point.Empty, tmp);
tmp = ss.GetColors(new Rectangle(0, 0, ss.Width, ss.Height));
ss.Update();
ret.Add(ss);
}
}
}
return ret;
}
示例2: LoadSurfacesFromFile
public static SurfaceCollection LoadSurfacesFromFile(string filePath, Size tileSize)
{
SurfaceCollection ret = new SurfaceCollection();
ret.AlphaBlending = true;
if (!File.Exists(filePath)) return ret;
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(filePath))
{
using (Surface s = new Surface(bmp))
{
s.Lock();
for (int i = 0; i < s.Width; i += tileSize.Width)
{
for (int j = 0; j < s.Height; j += tileSize.Height)
{
Surface ss = new Surface(tileSize.Width, tileSize.Height, 32, s.RedMask, s.GreenMask, s.BlueMask, s.AlphaMask);
ss.Transparent = true;
ss.AlphaBlending = true;
Color[,] tmp = s.GetColors(new Rectangle(i, j, tileSize.Width, tileSize.Height));
ss.Lock();
ss.SetPixels(Point.Empty, tmp);
tmp = ss.GetColors(new Rectangle(0, 0, ss.Width, ss.Height));
ss.Unlock();
ss.Update();
ret.Add(ss);
}
}
s.Unlock();
}
}
return ret;
}
示例3: SetAlpha
public static void SetAlpha(Surface s, float a)
{
if (s == null) return;
Color[,] colors = s.GetColors(new Rectangle(0, 0, s.Width, s.Height));
s.Lock();
for (int i = 0; i < colors.GetLength(0); i++)
{
for (int j = 0; j < colors.GetLength(1); j++)
{
Color c = colors[i, j];
int na = (int)(c.A * a);
colors[i, j] = Color.FromArgb(na < 0 ? 0 : (na > 255 ? 255 : na), c.R, c.G, c.B);
}
}
s.SetPixels(Point.Empty, colors);
s.Unlock();
s.Update();
}
示例4: SetColor
public static void SetColor(Surface s, Color c)
{
if (s == null) return;
Color[,] colors = s.GetColors(new Rectangle(0, 0, s.Width, s.Height));
s.Lock();
for (int i = 0; i < colors.GetLength(0); i++)
{
for (int j = 0; j < colors.GetLength(1); j++)
{
colors[i, j] = Color.FromArgb(colors[i, j].A, c.R, c.G, c.B);
}
}
s.SetPixels(Point.Empty, colors);
s.Unlock();
s.Update();
}
示例5: CreateColored
public static Surface CreateColored(Surface s, Color c0, Color c1)
{
if (s == null) return null;
Color[,] colors = s.GetColors(new Rectangle(0, 0, s.Width, s.Height));
for (int i = 0; i < colors.GetLength(0); i++)
{
for (int j = 0; j < colors.GetLength(1); j++)
{
Color c = colors[i, j];
float br = (c.R / 255.0f + c.G / 255.0f + c.B / 255.0f) / 3.0f;
if (br > 0.8f)
{
br = 1.0f;
}
else if (br < 0.2f)
{
br = 0.0f;
}
int r = (int)((1 - br) * c0.R + br * c1.R);
int g = (int)((1 - br) * c0.G + br * c1.G);
int b = (int)((1 - br) * c0.B + br * c1.B);
r = r < 0 ? 0 : (r > 255 ? 255 : r);
g = g < 0 ? 0 : (g > 255 ? 255 : g);
b = b < 0 ? 0 : (b > 255 ? 255 : b);
colors[i, j] = Color.FromArgb(c.A, r, g, b);
Color nc = Color.FromArgb(c.A, r, g, b);
}
}
Surface ns = new Surface(s.Width, s.Height, s.BitsPerPixel, s.RedMask, s.GreenMask, s.BlueMask, s.AlphaMask);
ns.AlphaBlending = s.AlphaBlending;
ns.Alpha = s.Alpha;
ns.Transparent = s.Transparent;
ns.TransparentColor = s.TransparentColor;
ns.Lock();
ns.SetPixels(Point.Empty, colors);
ns.Unlock();
ns.Update();
return ns;
}
示例6: Render
public virtual void Render(Surface s, Rectangle r)
{
if (_startLineSurface == null)
{
#warning パフォーマンスチェック
using (Surface ts = ResourceManager.LargePFont.Render("START", _foreColor, true))
{
_startLineSurface = new Surface(ts.Width + 20, view.Height, 32, ts.RedMask, ts.GreenMask, ts.BlueMask, ts.AlphaMask);
Color[,] tmp = ts.GetColors(new Rectangle(0, 0, ts.Width, ts.Height));
for (int i = 0; i < tmp.GetLength(0); i++)
{
for (int j = 0; j < tmp.GetLength(1); j++)
{
Color c = tmp[i, j];
tmp[i, j] = Color.FromArgb((int)(c.A / 2.0), c.R, c.G, c.B);
}
}
_startLineSurface.Lock();
_startLineSurface.SetPixels(new Point(20, (int)(_startLineSurface.Height / 2.0 - ts.Height / 2.0)), tmp);
_startLineSurface.Unlock();
}
_startLineSurface.Fill(new Rectangle(0, 0, 3, _startLineSurface.Height), Color.FromArgb(128, _foreColor.R, _foreColor.G, _foreColor.B));
_startLineSurface.Update();
_startLineSurface.AlphaBlending = true;
}
if (_goalLineSurface == null)
{
using (Surface ts = ResourceManager.LargePFont.Render("GOAL", _foreColor, true))
{
_goalLineSurface = new Surface(ts.Width + 20, view.Height, 32, ts.RedMask, ts.GreenMask, ts.BlueMask, ts.AlphaMask);
Color[,] tmp = ts.GetColors(new Rectangle(0, 0, ts.Width, ts.Height));
for (int i = 0; i < tmp.GetLength(0); i++)
{
for (int j = 0; j < tmp.GetLength(1); j++)
{
Color c = tmp[i, j];
tmp[i, j] = Color.FromArgb((int)(c.A / 2.0), c.R, c.G, c.B);
}
}
_goalLineSurface.Lock();
_goalLineSurface.SetPixels(new Point(0, (int)(_goalLineSurface.Height / 2.0 - ts.Height / 2.0)), tmp);
_goalLineSurface.Unlock();
}
_goalLineSurface.Fill(new Rectangle(_goalLineSurface.Width - 3, 0, 3, _goalLineSurface.Height), Color.FromArgb(128, _foreColor.R, _foreColor.G, _foreColor.B));
_goalLineSurface.Update();
_goalLineSurface.AlphaBlending = true;
}
renderBackground(s, r);
if (_startLineSurface.Width >= view.X && view.X + view.Width >= 0)
{
s.Blit(_startLineSurface, new Point(
(int)(r.X - view.X),
(int)(r.Y + view.Height / 2.0 - _startLineSurface.Height / 2.0)));
}
if (this.HasEnd)
{
if (this.Width >= view.X && view.X + view.Width >= this.Width - _goalLineSurface.Width)
{
s.Blit(_goalLineSurface, new Point(
(int)(r.X + this.Width - _goalLineSurface.Width - view.X),
(int)(r.Y + view.Height / 2.0 - _goalLineSurface.Height / 2.0)));
}
}
renderForeground(s, r);
}
示例7: decodeCursor
//.........这里部分代码省略.........
if (/*lots of stuff*/ false)
{
// direct byte copies
}
else
{
// pixel colour underneath goes here
v71 = 0;// 0xc8;
v72 = 0;// 0xfc;
v73 = 0;// 0xf8;
}
backBuffer[backCtr + 1] = v71;
backBuffer[backCtr + 2] = v72;
backBuffer[backCtr + 3] = v73;
backBuffer[backCtr] = 1;
if (isCursor4)
{
byte t = v71;
v71 = v73;
v73 = t;
}
if (alpha > 0)
{
if (alpha != 0xE0)
{
alpha = (byte)(((uint)alpha << 8) / 224);
r = (byte)((alpha * r + (256 - alpha) * v71) >> 8);
g = (byte)((alpha * g + (256 - alpha) * v72) >> 8);
b = (byte)((alpha * b + (256 - alpha) * v73) >> 8);
}
}
cursorBuffer[cursorCtr] = 1;
cursorBuffer[cursorCtr + 1] = r;
cursorBuffer[cursorCtr + 2] = g;
cursorBuffer[cursorCtr + 3] = b;
}
cursorCtr += 4;
backCtr += 4;
}
}
/*
for (int i = 0; i < cursor.height * cursor.width; i++, x++)
{
if (x >= cursor.width){
x = 0;
y++;
}
pix[x, y] = Color.FromArgb(cursor.frameData[0][i]);
}
* */
// perform interlace magic
Surface cSurf = new Surface(newCursor.width, newCursor.height);
Color[,] pix = new Color[cSurf.Width, cSurf.Height];
cursorCtr = 0;
Color last = Color.Black;
for (int y = 0; y < newCursor.height; y++)
{
for (int x = 0; x < newCursor.width; x++)
{
if (cursorBuffer[cursorCtr] > 0)
{
//sub_406720(v9 + v13, v6 + v11, *(_BYTE*)(memBlockC + 1), *(_BYTE*)(memBlockC + 2), *(_BYTE*)(memBlockC + 3));
/*(unsigned __int8)(*(_BYTE *)v3 >> (3))
+ ((unsigned __int8)(*(_BYTE *)(v3 + 1) >> (2)) << 5)
+ ((unsigned __int8)(*(_BYTE *)(v3 + 2) >> (3)) << 0xb) */
/*
* inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) {
r = CLIP<int>(y + ((1357 * (v - 128)) >> 10), 0, 255);
g = CLIP<int>(y - (( 691 * (v - 128)) >> 10) - ((333 * (u - 128)) >> 10), 0, 255);
b = CLIP<int>(y + ((1715 * (u - 128)) >> 10), 0, 255);*/
/*byte yy = memB[bctr + 1];
byte u = memB[bctr + 2];
byte v = memB[bctr + 3];
uint bb = (uint)(y + ((1357 * (v - 128)) >> 10));
uint g = (uint)(y - ((691 * (v - 128)) >> 10) - ((333 * (u - 128)) >> 10));
uint r = (uint)(y + ((1715 * (u - 128)) >> 10));
Color.FromArgb((byte)(r > 255 ? 255 : 0), (byte)(g > 255 ? 255 : g), (byte)(bb > 255 ? 255 : bb));*/
pix[x, y] = Color.FromArgb(cursorBuffer[cursorCtr + 1], cursorBuffer[cursorCtr + 2], cursorBuffer[cursorCtr + 3]);
last = pix[x, y];
cursorBuffer[cursorCtr] = 0;
}
cursorCtr += 4;
}
}
cSurf.SetPixels(new Point(0, 0), pix);
//cSurf.SaveBmp("h:\\test.bmp");
s.Fill(Color.Black);
s.Blit(cSurf, new Point(20, 20));
}