本文整理汇总了C#中Bitmap.RotateFlip方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.RotateFlip方法的具体用法?C# Bitmap.RotateFlip怎么用?C# Bitmap.RotateFlip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap.RotateFlip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FullScanPageCode39
public static void FullScanPageCode39(ref System.Collections.ArrayList CodesRead, Bitmap bmp, int numscans)
{
for (int i=0; i<4; i++)
{
bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
VScanPageCode39(ref CodesRead, bmp,numscans);
}
}
示例2: ResizeImage
public static Bitmap ResizeImage(Bitmap fullsizeImage, int maxWidth, int maxHeight, string imageName)
{
fullsizeImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
fullsizeImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
int imageWidth;
int imageHeight;
var newWidth = maxHeight * fullsizeImage.Width / fullsizeImage.Height;
if (newWidth > maxWidth)
{
imageHeight = fullsizeImage.Height * maxWidth / fullsizeImage.Width;
imageWidth = maxWidth;
}
else
{
imageWidth = newWidth;
imageHeight = maxHeight;
}
System.Drawing.Image newImage = fullsizeImage.GetThumbnailImage(imageWidth, imageHeight, null, IntPtr.Zero);
fullsizeImage.Dispose();
return (Bitmap)newImage;
}
示例3: CreateImage
public static void CreateImage (RotateFlipType rotate, int movex, int movey, string text, Bitmap dest, Graphics grdest)
{
Color clr;
Bitmap bmp = new Bitmap (80, 80, PixelFormat.Format32bppArgb);
Graphics gr = Graphics.FromImage (bmp);
gr.Clear (Color.White);
gr.DrawLine (p, 10.0F, 10.0F, 70.0F, 70.0F);
gr.DrawLine (p, 10.0F, 15.0F, 70.0F, 15.0F);
gr.DrawRectangle (p, 10.0F, 10.0F, 60.0F, 60.0F);
bmp.RotateFlip (rotate);
for (int y = 0; y < 80; y++) {
for (int x = 0; x < 80; x++) {
clr = bmp.GetPixel (x,y);
dest.SetPixel (x+movex, y+movey, clr);
}
}
grdest.DrawString (text, new Font ("Arial", 8), br, movex+5, movey+85);
}
示例4: MakeRoundedCorners
private static Image MakeRoundedCorners(Image image, int radius)
{
Bitmap bmp = new Bitmap(image, image.Width, image.Height);
using (Graphics g = Graphics.FromImage(bmp))
{
Brush brush = new SolidBrush(Color.White);
for (int i = 0; i < 4; i++)
{
Point[] cornerUpLeft = new Point[3];
cornerUpLeft[0].X = 0;
cornerUpLeft[0].Y = 0;
cornerUpLeft[1].X = radius;
cornerUpLeft[1].Y = 0;
cornerUpLeft[2].X = 0;
cornerUpLeft[2].Y = radius;
GraphicsPath pathCornerUpLeft = new GraphicsPath();
pathCornerUpLeft.AddArc(cornerUpLeft[0].X, cornerUpLeft[0].Y,
radius, radius, 180, 90);
pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
cornerUpLeft[1].X, cornerUpLeft[1].Y);
pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
cornerUpLeft[2].X, cornerUpLeft[2].Y);
g.FillPath(brush, pathCornerUpLeft);
pathCornerUpLeft.Dispose();
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
brush.Dispose();
g.Dispose();
}
return bmp;
}
示例5: Bitmap
/// <summary> buffer callback, COULD BE FROM FOREIGN THREAD. </summary>
int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
{
Bitmap bitmap = new Bitmap(m_videoWidth, m_videoHeight, m_stride, PixelFormat.Format24bppRgb, pBuffer);
bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
// byte[] bmp = ByteTools.BmpToBytes(bitmap, PixelFormat.Format24bppRgb);
VisionMessage vm = new VisionMessage(m_videoHeight, m_videoWidth, ByteTools.pixelFormatToBPP(PixelFormat.Format24bppRgb), bitmap);
msgService.sendMsg(vm);
Thread.Sleep((int)(videoInfoHeader.AvgTimePerFrame/20000));
return 0;
}
示例6: GenerateCardImages
public void GenerateCardImages()
{
int s = 10;
int h = 100;
int w = 300;
foreach (var card in Card.GetCards())
{
var img = new Bitmap(w, w);
var graphics = Graphics.FromImage(img);
graphics.Clear(Color.White);
Brush brush;
if (card.Fill == Card.Fills.Solid.ToString())
{
brush = new SolidBrush(card.Color);
}
else if (card.Fill == Card.Fills.Striped.ToString())
{
brush = new HatchBrush(HatchStyle.WideUpwardDiagonal, Color.White, card.Color);
}
else
{
brush = new SolidBrush(Color.White);
}
// shape
Rectangle[] rectangles = new Rectangle[card.Number];
for (int i = 0; i < card.Number; i++)
{
int x = s;
int width = w - (s * 2);
int y = (i * h) + s;
int height = h - (s * 2);
var rectangle = new Rectangle(x, y, width, height);
if (card.Shape == Card.Shapes.Rectangle.ToString())
{
rectangles[i] = rectangle;
if (card.Fill == Card.Fills.Empty.ToString())
{
if (rectangles.Count() > 0)
{
graphics.DrawRectangle(new Pen(card.Color), rectangle);
}
}
else
{
graphics.FillRectangle(brush, rectangle);
}
}
else if (card.Shape == Card.Shapes.Oval.ToString())
{
if (card.Fill == Card.Fills.Empty.ToString())
{
graphics.DrawEllipse(new Pen(card.Color), rectangle);
}
else
{
graphics.FillEllipse(brush, rectangle);
}
}
else if (card.Shape == Card.Shapes.Diamond.ToString())
{
var sp = i == 0 ? s : s * 2;
var x1 = width;
var y1 = (height / 2) + (h * i);
var x2 = (width / 2);
var y2 = i * height;
var x3 = s / 2;
var y3 = (height / 2) + (h * i);
var x4 = width / 2;
// var y4 =(height * (i+1));
var y4 = y1 + (height / 2);
var points = new Point[]{
new Point(x1 + s, y1 - (s*i)+ sp - s),
new Point(x2 + s, y2+ (s* (i+1))+ sp-s),
new Point(x3, y3 - (s*i)+ sp-s ),
new Point(x4 + s, y4 - (s*i)+ sp-s)
};
if (card.Fill == Card.Fills.Empty.ToString())
{
graphics.DrawPolygon(new Pen(card.Color), points);
}
else
{
graphics.FillPolygon(brush, points);
}
}
}
var path = string.Format("~/Images/Cards/SetImage-{0}.png", card.CardID);
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
img.Save(HttpContext.Current.Server.MapPath(path), ImageFormat.Png);
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Haal de afbeelding op
String image = (String)Session["filename"];
// Maak de nieuwe bitmap
Bitmap bitmap = new Bitmap(image);
// Haal de actie op
String action = (String)Session["action"];
switch (action)
{
case "grayscale": // Grijswaarden
// We converteren elk punt naar z'n grijswaarde
for (int i = 0; i < bitmap.Width; i++)
{
for (int j = 0; j < bitmap.Height; j++)
{
// Haal de pixel op
Color currentPixelColor = bitmap.GetPixel(i, j);
// Formule via http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
int gray = (int)(0.299 * currentPixelColor.R + 0.587 * currentPixelColor.G + 0.114 * currentPixelColor.B);
// Zet de pixel terug met z'n grijswaarde
bitmap.SetPixel(i, j, Color.FromArgb(gray, gray, gray));
}
}
break;
case "scale": // Herschaling
Double width = (Double)Session["width"];
Double height = (Double)Session["height"];
// Bereken de nieuwe hoogte & breedte
int newHeight = (int)(height * bitmap.Height);
int newWidth = (int)(width * bitmap.Width);
// Maak een nieuwe bitmap met de nieuwe hoogte & breedte
bitmap = new Bitmap(bitmap, newWidth, newHeight);
break;
case "rotate": // Rotatie
String angle = (String)Session["angle"];
// Over welke hoek willen we roteren?
switch (angle)
{
case "90":
bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case "180":
bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case "270":
bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
break;
}
// Zet tekst op de afbeelding
Graphics graphics = Graphics.FromImage(bitmap);
graphics.DrawString("Groep 1: Cynric Huys & Tom Naessens", new Font("Comic Sans", 15), Brushes.White, new Point(2, 2));
// Zet het contenttype van de pagina op JPEG
Response.ContentType = "image/JPEG";
// Schrijf de JPEG naar de outputstream (aka de pagina)
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
}
示例8: Main
static void Main()
{
foreach (string type_name in Enum.GetNames(typeof(RotateFlipType)))
{
RotateFlipType type = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), type_name);
if (type_name != type.ToString())
Console.WriteLine("- processing {0} ({1})...", type_name, type);
else
Console.WriteLine("- processing {0}...", type_name);
Bitmap result = null;
try
{
result = load("24bit.png");
result.RotateFlip(type);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION (24-bit): {0}: {1}", e.GetType().Name, e.Message);
if (result != null) try { result.Dispose(); } catch {}
result = null;
}
if (result != null)
result.Save("24bit_" + type_name + ".png", ImageFormat.Png);
try { result.Dispose(); } catch {}
try
{
Bitmap intermediate = load("24bit.png");
result = new Bitmap(intermediate.Width, intermediate.Height, PixelFormat.Format16bppRgb565);
using (Graphics g = Graphics.FromImage(result))
{
Rectangle bounds = new Rectangle(0, 0, result.Width, result.Height);
g.DrawImage(intermediate, bounds, bounds, GraphicsUnit.Pixel);
}
result.RotateFlip(type);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION (16-bit): {0}: {1}", e.GetType().Name, e.Message);
if (result != null) try { result.Dispose(); } catch {}
result = null;
}
if (result != null)
result.Save("16bit_" + type_name + ".png", ImageFormat.Png);
try { result.Dispose(); } catch {}
try
{
result = load("8bit.png");
result.RotateFlip(type);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION (8-bit): {0}: {1}", e.GetType().Name, e.Message);
if (result != null) try { result.Dispose(); } catch {}
result = null;
}
if (result != null)
result.Save("8bit_" + type_name + ".png", ImageFormat.Png);
try { result.Dispose(); } catch {}
}
Console.WriteLine("done!");
}