本文整理汇总了C#中SdlDotNet.Graphics.Surface.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Convert方法的具体用法?C# Surface.Convert怎么用?C# Surface.Convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdlDotNet.Graphics.Surface
的用法示例。
在下文中一共展示了Surface.Convert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
if (File.Exists(Path.Combine(dataDirectory, "Background1.png")))
{
filePath = "";
}
Video.WindowIcon();
Video.WindowCaption =
"SDL.NET - Bomb Run";
screen = Video.SetVideoMode(640, 480);
tempSurface = new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "Background1.png")));
background = tempSurface.Convert();
tempSurface = new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "Background2.png")));
alternateBackground = tempSurface.Convert();
temporary = screen.CreateCompatibleSurface(32, 32);
temporary.TransparentColor = Color.FromArgb(0, 255, 0, 255);
temporary.Transparent = true;
player = new Player(new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "Head.bmp"))), new Point(screen.Width / 2 - 16,
screen.Height - 32));
players.Add(player);
players.EnableKeyboardEvent();
bullets.EnableTickEvent();
master.EnableTickEvent();
for (int i = 0; i < 25; i++)
{
bombs.Add(new Bomb(new Surface(Path.Combine(filePath, Path.Combine(dataDirectory, "Bomb.bmp")))));
}
foreach (Sprite bomb in bombs)
{
master.Add(bomb);
}
foreach (Sprite playerSprite in players)
{
master.Add(playerSprite);
}
Mouse.ShowCursor = false;
Events.KeyboardDown +=
new EventHandler<KeyboardEventArgs>(Keyboard);
Events.Quit += new EventHandler<QuitEventArgs>(Quit);
player.WeaponFired += new EventHandler<FireEventArgs>(PlayerWeaponFired);
Events.Tick += new EventHandler<TickEventArgs>(OnTick);
Events.Run();
}
示例2: LoadImages
// utility routines
public static ArrayList LoadImages(string[] imageNames)
{
if (imageNames == null)
{
throw new ArgumentNullException("imageNames");
}
/*Loads a list of images.
image_names: The filenames of the images to load: list of string
*/
ArrayList images = new ArrayList();
//Load images using a colorkey transparency of whitest white
//int[] colorkey={255,255,255};
foreach (string file_name in imageNames)
{
Surface image = new Surface(file_name);
image = image.Convert();
image.TransparentColor = Color.FromArgb(255, 255, 255);
image.Transparent = true;
images.Add(image);
}
return (images);
}
示例3: LoadSurface
public static SdlDotNet.Graphics.Surface LoadSurface(string filePath, bool convert, bool transparent)
{
filePath = IO.Paths.CreateOSPath(filePath);
Surface returnSurf;
switch (System.IO.Path.GetExtension(filePath)) {
case ".pmugfx": {
if (IO.IO.FileExists(filePath)) {
using (MemoryStream stream = new MemoryStream(DecryptSurface(filePath)))
{
Bitmap bitmap = (Bitmap)Image.FromStream(stream);
returnSurf = new Surface(bitmap);
if (convert)
{
Surface returnSurf2 = returnSurf.Convert();
returnSurf2.Transparent = true;
returnSurf.Close();
return returnSurf2;
}
else
{
return returnSurf;
}
}
} else {
return null;
}
}
case ".gif":
case ".png":
default: {
if (IO.IO.FileExists(filePath)) {
using (FileStream stream = File.OpenRead(filePath))
{
if (transparent)
{
Bitmap bitmap = (Bitmap)Image.FromStream(stream);
Bitmap clone = new Bitmap(bitmap.Width, bitmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (Graphics gr = Graphics.FromImage(clone))
{
gr.DrawImage(bitmap, new Rectangle(0, 0, clone.Width, clone.Height));
}
returnSurf = new Surface(clone);
}
else
{
Bitmap bitmap = (Bitmap)Image.FromStream(stream);
returnSurf = new Surface(bitmap);
}
if (convert)
{
Surface returnSurf2 = returnSurf.Convert();
returnSurf2.Transparent = true;
returnSurf.Close();
return returnSurf2;
}
else
{
return returnSurf;
}
}
} else {
return null;
}
}
}
}
示例4: LoadPMUGfx
internal static Surface LoadPMUGfx(byte[] imageBytes, bool convert)
{
Surface returnSurf = new Surface(DecryptSurface(imageBytes));
if (convert) {
Surface returnSurf2 = returnSurf.Convert();
returnSurf2.Transparent = true;
returnSurf.Close();
return returnSurf2;
} else {
return returnSurf;
}
}
示例5: ScoreCard
public ScoreCard(Player player, Point displayPosition)
{
this.player = player;
this.displayPosition = displayPosition;
this.kills = 0;
this.defeats = 0;
this.suicides = 0;
this.font = new Font(Configuration.InfoBar.PlayerStatusDisplayFontFilename, Configuration.InfoBar.PlayerStatusDisplayFontSize);
Surface scoreCardSurface = new Surface(Configuration.InfoBar.PlayerStatusDisplayImageFilename);
Point position = new Point(Configuration.InfoBar.XBuffer, Configuration.InfoBar.YBuffer);
// Show the ship's picture.
scoreCardSurface.Blit(this.player.Ship.ShipPhotoSurface, position);
position.X += this.player.Ship.ShipPhotoSurface.Width + Configuration.InfoBar.XBuffer;
using (Surface text = font.Render(string.Format("Player {0}", player.Number), Configuration.Ships.Shields.InfoDisplayPlayerFontColor))
{
text.Transparent = true;
scoreCardSurface.Blit(text, position);
}
int xPosition = position.X + Configuration.InfoBar.FirstColumn_PixelsToIndent;
this.shieldsText = font.Render("Shields:", Configuration.Ships.Shields.InfoDisplayStrongColor, true);
this.shieldsText.Transparent = true;
scoreCardSurface.Blit(shieldsText, new Point(xPosition, position.Y + this.font.LineSize + 1));
this.bulletsText = font.Render("Bullets:", Configuration.Ships.Cannon.InfoDisplayStrongBulletCountColor, true);
this.bulletsText.Transparent = true;
scoreCardSurface.Blit(bulletsText, new Point(xPosition, position.Y + this.font.LineSize * 2 + 1));
xPosition = position.X + Configuration.InfoBar.SecondColumn_PixelsToIndent;
this.killsText = font.Render("Kills:", Configuration.InfoBar.CounterTextColor, true);
this.killsText.Transparent = true;
scoreCardSurface.Blit(killsText, new Point(xPosition, position.Y));
this.defeatsText = font.Render("Defeats:", Configuration.InfoBar.CounterTextColor, true);
this.defeatsText.Transparent = true;
scoreCardSurface.Blit(defeatsText, new Point(xPosition, position.Y + this.font.LineSize + 1));
this.suicidesText = font.Render("Suicides:", Configuration.InfoBar.CounterTextColor, true);
this.suicidesText.Transparent = true;
scoreCardSurface.Blit(suicidesText, new Point(xPosition, position.Y + this.font.LineSize * 2 + 1));
this.scoreCard = scoreCardSurface.Convert(Video.Screen, true, false);
}
示例6: OrbitClash
public OrbitClash()
{
Video.WindowIcon();
Video.SetVideoMode(Configuration.DisplaySize.Width, Configuration.DisplaySize.Height, false);
Video.WindowCaption = Configuration.Title;
Mixer.ChannelsAllocated = Configuration.MaxSoundChannels;
this.theGameHasBegun = false;
this.particleSystem = new ParticleSystem();
this.mainTitle = new MainTitle();
Surface infoBarSurface = new Surface(Configuration.InfoBar.ImageFilename);
this.infoBar = infoBarSurface.Convert(Video.Screen, true, false);
// Player 1.
this.player1 = new Player(1);
this.player1.LeftKey = Configuration.Controls.Player1.Left;
this.player1.RightKey = Configuration.Controls.Player1.Right;
this.player1.UpKey = Configuration.Controls.Player1.Up;
this.player1.DownKey = Configuration.Controls.Player1.Down;
this.player1.FireKey = Configuration.Controls.Player1.Fire;
// Player 2.
this.player2 = new Player(2);
this.player2.LeftKey = Configuration.Controls.Player2.Left;
this.player2.RightKey = Configuration.Controls.Player2.Right;
this.player2.UpKey = Configuration.Controls.Player2.Up;
this.player2.DownKey = Configuration.Controls.Player2.Down;
this.player2.FireKey = Configuration.Controls.Player2.Fire;
this.bulletShipImpactSound = new Sound(Configuration.Bullets.BulletShipImpactSoundFilename);
this.bulletShipImpactSound.Volume = Configuration.SoundVolume;
this.bulletShipImpactBounceSound = new Sound(Configuration.Bullets.BulletShipImpactBounceSoundFilename);
this.bulletShipImpactBounceSound.Volume = Configuration.SoundVolume;
this.bulletPlanetImpactSound = new Sound(Configuration.Bullets.BulletPlanetImpactSoundFilename);
this.bulletPlanetImpactSound.Volume = Configuration.SoundVolume;
this.shipShipImpactSound = new Sound(Configuration.Ships.ShipShipImpactSoundFilename);
this.shipShipImpactSound.Volume = Configuration.SoundVolume;
// Setup screen bounce-boundary manipulator.
this.boundaryManipulator = new ParticleBoundary(new Rectangle(Configuration.PlayArea.Location, Configuration.PlayArea.Size));
this.particleSystem.Manipulators.Add(this.boundaryManipulator);
// Set up star-background.
Surface backgroundSurface = new Surface(Configuration.PlayAreaBackgroundImageFilename);
this.background = backgroundSurface.Convert(Video.Screen, true, false);
// Setup the planet.
Point planetLocation = new Point(Configuration.PlayArea.Width / 2, Configuration.PlayArea.Height / 2);
this.planet = new Planet(Configuration.Planet.ImageFilename, Configuration.Planet.ImageTransparentColor, planetLocation, Configuration.Planet.ImageScale);
this.particleSystem.Add(this.planet);
// Draw the planetary halo onto the background.
if (Configuration.Planet.ShowPlanetaryHalo)
{
Point haloPosition = new Point(this.planet.Center.X - Configuration.Planet.GravityWellRadius, this.planet.Center.Y - Configuration.Planet.GravityWellRadius);
this.background.Blit(this.planet.HaloSurface, haloPosition);
}
// Setup the gravity manipulator.
this.gravityManipulator = new GravityWell(this.planet.Center, Configuration.Planet.GravityWellRadius, Configuration.Planet.GravityPower);
this.particleSystem.Manipulators.Add(this.gravityManipulator);
// Setup speed limit manipulator.
this.speedLimitManipulator = new SpeedLimit(Configuration.UniversalSpeedLimit);
//this.particleSystem.Manipulators.Add(this.speedLimitManipulator);
Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(this.KeyboardDown);
Events.KeyboardUp += new EventHandler<KeyboardEventArgs>(this.KeyboardUp);
Events.Fps = Configuration.Fps;
Events.Tick += new EventHandler<TickEventArgs>(this.Tick);
Events.Quit += new EventHandler<QuitEventArgs>(this.Quit);
}
示例7: GetPlanetSprite
private static Sprite GetPlanetSprite(string imageFilename, Color bitmap_TransparentColor, float scale)
{
Bitmap image = new Bitmap(imageFilename);
Surface surface = new Surface(image);
// Convert it for display.
surface.Convert(Video.Screen, true, false);
// Scale it.
surface = surface.CreateScaledSurface(scale);
// Set the transparent color.
surface.Transparent = true;
surface.TransparentColor = bitmap_TransparentColor;
Sprite sprite = new Sprite(surface);
return sprite;
}