本文整理汇总了C#中System.Drawing.Bitmap.RotateFlip方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Bitmap.RotateFlip方法的具体用法?C# System.Drawing.Bitmap.RotateFlip怎么用?C# System.Drawing.Bitmap.RotateFlip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Bitmap
的用法示例。
在下文中一共展示了System.Drawing.Bitmap.RotateFlip方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FlipImage
private static void FlipImage(string filepath, string targetDirectoryPath)
{
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(filepath);
bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
bitmap.Save(System.IO.Path.Combine(targetDirectoryPath, System.IO.Path.GetFileName(filepath)));
}
示例2: FlipImages
private static void FlipImages(string sourceDirectoryPath, string targetDirectoryPath)
{
var filesInDirectory = System.IO.Directory.GetFiles(sourceDirectoryPath);
Parallel.ForEach(filesInDirectory,
(currentFile) =>
{
string filename = System.IO.Path.GetFileName(currentFile);
// Warning: The Console will slow down our loop
Console.WriteLine("Processing {0} on thread {1}", filename, Thread.CurrentThread.ManagedThreadId);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(currentFile);
bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
bitmap.Save(System.IO.Path.Combine(targetDirectoryPath, filename));
});
}
示例3: FilesToFlipChosen
private void FilesToFlipChosen(object sender, System.ComponentModel.CancelEventArgs e)
{
if (e.Cancel)
{
return;
}
var openFileDialog = sender as OpenFileDialog;
foreach (var filename in openFileDialog.FileNames)
{
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(filename);
bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
bitmap.Save(filename);
ImageSource source = new BitmapImage(new Uri(filename));
this.Images.Add(source);
}
}
示例4: DoEffect
//.........这里部分代码省略.........
R = 255 * (R + 0.5);
R = System.Math.Max(0, System.Math.Min(255, R));
G = c.G / 255.0 - 0.5;
G = G >= 0 ? System.Math.Pow(G, 1.0 / contrast) : -System.Math.Pow(-G, 1.0 / contrast);
G = 255 * (G + 0.5);
G = System.Math.Max(0, System.Math.Min(255, G));
B = c.B / 255.0 - 0.5;
B = B >= 0 ? System.Math.Pow(B, 1.0 / contrast) : -System.Math.Pow(-B, 1.0 / contrast);
B = 255 * (B + 0.5);
B = System.Math.Max(0, System.Math.Min(255, B));
fp.SetPixel(i, j, System.Drawing.Color.FromArgb(c.A, (int)R, (int)G, (int)B));
}
}
fp.Unlock(true);
}
break;
case eEffect.BLOCKS: //Blocks
{
System.Drawing.Image.GetThumbnailImageAbort dummyCallback = new System.Drawing.Image.GetThumbnailImageAbort(ResizeAbort);
int size = parameter;
if (size <= 0) size = pEffect[(int)_effect];
_dImg = _dImg.GetThumbnailImage(bmap.Width / size, bmap.Height / size, dummyCallback, IntPtr.Zero);
_dImg = _dImg.GetThumbnailImage(bmap.Width, bmap.Height, dummyCallback, IntPtr.Zero);
bmap = new System.Drawing.Bitmap(_dImg);
}
break;
case eEffect.REFLECT: //Reflect
{
int mode = parameter;
if (mode <= 0) mode = pEffect[(int)_effect];
bmap.RotateFlip(mode == 1 ? System.Drawing.RotateFlipType.RotateNoneFlipY : System.Drawing.RotateFlipType.RotateNoneFlipX);
}
break;
case eEffect.JAGGED: //Jagged
{
System.Drawing.Color c;
System.Drawing.Bitmap copy = (System.Drawing.Bitmap)bmap.Clone();
FastPixel fpCopy = new FastPixel(copy);
int amount = parameter;
if (amount <= 0) amount = pEffect[(int)_effect];
bool up = true, left = false;
int ii, jj;
FastPixel fp = new FastPixel(bmap);
for (int i = 0; i < fp.Width; i++)
{
if (i % amount == 0) up = !up;
for (int j = 0; j < fp.Height; j++)
{
if (j % amount == 0) left = !left;
ii = left ? System.Math.Max(0, i - amount) : System.Math.Min(fp.Width - 1, i + amount);
jj = up ? System.Math.Max(0, j - amount) : System.Math.Min(fp.Height - 1, j + amount);
c = fpCopy.GetPixel(ii, jj);
fp.SetPixel(i, j, c);
}
}
fpCopy.Unlock(false);
fp.Unlock(true);
}
break;
case eEffect.ROTATE: //Rotate
{
int mode = parameter;
if (mode <= 0) mode = pEffect[(int)_effect];
示例5: RotateUsingGdi
private Tuple<MediaObjectRotation, Size> RotateUsingGdi(string filePath, int jpegQuality)
{
var actualRotation = GalleryObject.CalculateNeededRotation();
if (actualRotation <= MediaObjectRotation.Rotate0)
{
return new Tuple<MediaObjectRotation, Size>(actualRotation, Size.Empty);
}
// Get reference to the bitmap from which the optimized image will be generated.
using (var originalBitmap = new System.Drawing.Bitmap(filePath))
{
var imgFormat = originalBitmap.RawFormat; // Need to grab the format before we rotate or else we lose it (it changes to MemoryBmp)
try
{
originalBitmap.RotateFlip(GetRotateFlipType());
}
catch (System.Runtime.InteropServices.ExternalException)
{
throw new UnsupportedImageTypeException();
}
ImageHelper.SaveImageToDisk(originalBitmap, GalleryObject.Original.FileNamePhysicalPath, imgFormat, jpegQuality);
return new Tuple<MediaObjectRotation, Size>(actualRotation, new Size(originalBitmap.Width, originalBitmap.Height));
}
}
示例6: ToBitmap
public static System.Drawing.Bitmap ToBitmap(this UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel model, int width, int height, UniversalEditor.ObjectModels.Multimedia3D.Pose.PoseObjectModel pose)
{
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
graphics.Clear(System.Drawing.Color.Black);
IntPtr hdc = graphics.GetHdc();
Canvas canvas = new Canvas(hdc, bitmap.PixelFormat);
canvas.MakeCurrent();
canvas.Matrix.Mode = MatrixMode.Projection;
canvas.Matrix.Reset();
Internal.GLU.Methods.gluPerspective(45.0, 640 / 480, 0.0, 45.0);
canvas.EnableDepthTesting = true;
canvas.EnableNormalization = true;
canvas.EnableTexturing = true;
Internal.OpenGL.Methods.glTexEnv(Internal.OpenGL.Constants.TextureEnvironmentTarget.TextureEnvironment, Internal.OpenGL.Constants.TextureEnvironmentParameterName.TextureEnvironmentMode, Internal.OpenGL.Constants.TextureEnvironmentParameterValue.Modulate);
canvas.CullingMode = CullingMode.Front;
canvas.EnableBlending = true;
Internal.OpenGL.Methods.glBlendFunc(Internal.OpenGL.Constants.GLBlendFunc.SourceAlpha, Internal.OpenGL.Constants.GLBlendFunc.OneMinusSourceAlpha);
Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.AlphaTesting);
Internal.OpenGL.Methods.glAlphaFunc(Internal.OpenGL.Constants.GLAlphaFunc.GreaterOrEqual, 0.05f);
World.Lights[0].Position = new PositionVector4(0.45f, 1.45f, -4.0f, 0.0f);
World.Lights[0].DiffuseColor = Color.FromRGBA(0.9f, 0.9f, 0.9f, 1.0f);
World.Lights[0].AmbientColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
World.Lights[0].SpecularColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
World.Lights[0].Enabled = true;
canvas.Matrix.Mode = MatrixMode.Projection;
canvas.Reset();
canvas.Translate(0.0, -1, 0.5);
canvas.Scale(0.05, 0.08, 0.1);
canvas.Matrix.Mode = MatrixMode.ModelView;
canvas.DrawModel(model);
graphics.ReleaseHdc();
graphics.Flush();
bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
if (pose != null)
{
}
return bitmap;
}
示例7: OnUpdateFrame
protected override void OnUpdateFrame (FrameEventArgs e)
{
frameCpt++;
if (frameCpt == uint.MaxValue)
frameCpt = 0;
base.OnUpdateFrame (e);
// if (Keyboard [OpenTK.Input.Key.ShiftLeft]) {
// float MoveSpeed = 10f;
// //light movment
// if (Keyboard [OpenTK.Input.Key.Up])
// vLight.X -= MoveSpeed;
// else if (Keyboard [OpenTK.Input.Key.Down])
// vLight.X += MoveSpeed;
// else if (Keyboard [OpenTK.Input.Key.Left])
// vLight.Y -= MoveSpeed;
// else if (Keyboard [OpenTK.Input.Key.Right])
// vLight.Y += MoveSpeed;
// else if (Keyboard [OpenTK.Input.Key.PageUp])
// vLight.Z += MoveSpeed;
// else if (Keyboard [OpenTK.Input.Key.PageDown])
// vLight.Z -= MoveSpeed;
// //updateShadersMatrices ();
// //GL.Light (LightName.Light0, LightParameter.Position, vLight);
// }
// if (depthSortingDone) {
// foreach (Tetra.VAOItem<Tetra.VAOInstancedData> item in transparentItemsVao.Meshes)
// item.UpdateInstancesData();
//
// depthSortingDone = false;
// }
Animation.ProcessAnimations ();
animate ();
if (queryUpdateShaderMatices) {
queryUpdateShaderMatices = false;
updateShadersMatrices ();
}
if (queryGammaUpdate) {
queryGammaUpdate = false;
shaderSharedData.Update ();
queryUpdateGridCache = true;
}
//if (queryUpdateShadowMap) {
queryUpdateShadowMap = false;
//}
updateShadowMap ();
material.Update (terrainMat);
terrain.Update (this, queryUpdateGridCache);
queryUpdateGridCache = false;
if (queryTextureViewerUpdate || (autoUpdate && frameCpt % 60 == 0)) {
queryTextureViewerUpdate = false;
if (viewedTexture < 0) {
GL.ReadBuffer (ReadBufferMode.Back);
if (viewedTexture == -1) {
// save backbuffer color
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap (ClientSize.Width, ClientSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) {
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits (
new System.Drawing.Rectangle (0, 0, ClientSize.Width, ClientSize.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.ReadPixels (0, 0, ClientSize.Width, ClientSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0);
SwapBuffers ();
bmp.UnlockBits (bmpData);
bmp.RotateFlip (System.Drawing.RotateFlipType.RotateNoneFlipY);
bmp.Save (ViewedImgPath);
}
} else if (viewedTexture == -2) {
saveBackBufferDepth ();
// using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap (ClientSize.Width, ClientSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) {
// System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits (
// new System.Drawing.Rectangle (0, 0, ClientSize.Width, ClientSize.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// GL.ReadPixels (0, 0, ClientSize.Width, ClientSize.Height, PixelFormat.DepthComponent, PixelType.UnsignedByte, bmpData.Scan0);
// SwapBuffers ();
// bmp.UnlockBits (bmpData);
// bmp.RotateFlip (System.Drawing.RotateFlipType.RotateNoneFlipY);
// bmp.Save (ViewedImgPath);
// }
}
} else {
Tetra.Texture.SaveTextureFromId (viewedTexture, viewedImgPath);
}
ViewedImgPath = viewedImgPath;//notify value changed
}
}