当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.RotateFlip方法代码示例

本文整理汇总了C#中System.Drawing.Bitmap.RotateFlip方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.RotateFlip方法的具体用法?C# Bitmap.RotateFlip怎么用?C# Bitmap.RotateFlip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Bitmap的用法示例。


在下文中一共展示了Bitmap.RotateFlip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddFrame

        public void AddFrame(Bitmap bmp)
        {
            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);

            BitmapData bmpDat = bmp.LockBits(
                new Rectangle(0, 0, bmp.Width, bmp.Height),
                ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);

            if (countFrames == 0)
            {
                this.stride = (UInt32)bmpDat.Stride;
                this.width = bmp.Width;
                this.height = bmp.Height;
                CreateStream();
            }

            int result = AviReadingMethods.AVIStreamWrite(aviStream,
                countFrames, 1,
                bmpDat.Scan0,
                (Int32)(stride * height),
                0, 0, 0);

            if (result != 0)
            {
                throw new Exception("Problem podczas otwierania pliku AVI" + result.ToString());
            }

            bmp.UnlockBits(bmpDat);
            countFrames++;
        }
开发者ID:Rybzor,项目名称:Stego,代码行数:30,代码来源:AviFileWriting.cs

示例2: Draw

        public void Draw(Graphics graphics)
        {
            bitmap.Dispose();
            bitmap = new Bitmap("c:/sprite.jpg");

            switch (currentDirrection) {

                case "left": {
                    bitmap.RotateFlip(RotateFlipType.Rotate180FlipY);
                    break;
                }

                case "up": {
                    bitmap.RotateFlip(RotateFlipType.Rotate270FlipX);
                    break;
                }

                case "down": {
                    bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;
                }

                default: {
                    break;
                }

            }

            graphics.DrawImage(bitmap,displayArea);
        }
开发者ID:Toonic,项目名称:MazeLikeGame,代码行数:30,代码来源:MazeCharacter.cs

示例3: rotateImage

        public Image rotateImage(Image img, int angle)
        {
            
            var bmp = new Bitmap(img);

            using (Graphics gfx = Graphics.FromImage(bmp))
            {
                gfx.Clear(Color.White);
                gfx.DrawImage(img, 0, 0, img.Width, img.Height);
            }

            if(angle == 90)
            {
                bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }
            else if(angle == 180 )
            {
                bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }
            else if (angle == 270)
            {
                bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }

            return bmp;
        }
开发者ID:Broams,项目名称:holography,代码行数:26,代码来源:HologramDisplay1.cs

示例4: ProcessBuffer

        public int ProcessBuffer(double sampleTime, IntPtr buffer, int bufferLength)
        {
            using (Bitmap bitmap = new Bitmap(_width, _height, _format))
            {
                BitmapData data = bitmap.LockBits(_bounds, ImageLockMode.ReadWrite, _format);

                NativeMethods.CopyMemory(data.Scan0, buffer, (uint) bufferLength);

                bitmap.UnlockBits(data);

                if (_flipImages) bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

                UpdateImage(sampleTime, bitmap);

                if (_flipImages) bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

                data = bitmap.LockBits(_bounds, ImageLockMode.ReadOnly, _format);

                NativeMethods.CopyMemory(buffer, data.Scan0, (uint) bufferLength);

                bitmap.UnlockBits(data);
            }

            return 0;
        }
开发者ID:naik899,项目名称:VideoMaker,代码行数:25,代码来源:AbstractWatermarkParticipant.cs

示例5: LoadDisplay

        private void LoadDisplay(PictureBox pBox, Bitmap robotBitmap, Robot robot)
        {
            switch(robot.getOrientation())
            {
                case("W"):
                {
                    //  Rotate 90 degrees counter clockwise
                    robotBitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    pBox.Image = robotBitmap;
                }
                break;
                case ("S"):
                    {
                        //  Rotate 90 degrees counter clockwise
                        robotBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        pBox.Image = robotBitmap;
                    }
                    break;
                case ("E"):
                    {
                        //  Rotate 90 degrees counter clockwise
                        robotBitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        pBox.Image = robotBitmap;
                    }
                    break;
                default:
                    break;
            }

            //  Position the robot's initial position on the arena
            pBox.Location = new Point(X_map(robot.getPositionX()), Y_map(robot.getPositionY()));
        }
开发者ID:pascalhow,项目名称:RobotWars,代码行数:32,代码来源:RobotWarBattleField_Form.cs

示例6: ProcessImage

        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">The current instance of the 
        /// <see cref="T:ImageProcessor.ImageFactory" /> class containing
        /// the image to process.</param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image image = factory.Image;

            try
            {
                const int Orientation = (int)ExifPropertyTag.Orientation;
                if (!factory.PreserveExifData && factory.ExifPropertyItems.ContainsKey(Orientation))
                {
                    newImage = new Bitmap(image);

                    int rotationValue = factory.ExifPropertyItems[Orientation].Value[0];
                    switch (rotationValue)
                    {
                        case 1: // Landscape, do nothing
                            break;

                        case 8: // Rotated 90 right
                            // De-rotate:
                            newImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                            break;

                        case 3: // Bottoms up
                            newImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
                            break;

                        case 6: // Rotated 90 left
                            newImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            break;
                    }

                    // Reassign the image.
                    image.Dispose();
                    image = newImage;
                }
            }
            catch (Exception ex)
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return image;
        }
开发者ID:ruanzx,项目名称:ImageProcessor,代码行数:58,代码来源:AutoRotate.cs

示例7: AnalyseLayout_RotatedImage

 public void AnalyseLayout_RotatedImage(RotateFlipType? rotation)
 {
     using (var img = new Bitmap(@".\phototest.tif")) {
         if (rotation.HasValue) img.RotateFlip(rotation.Value);
         engine.DefaultPageSegMode = PageSegMode.AutoOsd;
         using (var page = engine.Process(img)) {
             using (var pageLayout = page.GetIterator()) {
                 pageLayout.Begin();
                 do {
                     var result = pageLayout.GetProperties();
                     // Note: The orientation always seem to be 'PageUp' in Tesseract 3.02 according to this test.
                     Assert.That(result.Orientation, Is.EqualTo(Orientation.PageUp));
                     if (rotation == RotateFlipType.Rotate180FlipNone) {
                         // This isn't correct...
                         Assert.That(result.WritingDirection, Is.EqualTo(WritingDirection.LeftToRight));
                         Assert.That(result.TextLineOrder, Is.EqualTo(TextLineOrder.TopToBottom));
                     } else if (rotation == RotateFlipType.Rotate90FlipNone) {
                         Assert.That(result.WritingDirection, Is.EqualTo(WritingDirection.TopToBottom));
                         Assert.That(result.TextLineOrder, Is.EqualTo(TextLineOrder.RightToLeft));
                     } else if (rotation == null) {
                         Assert.That(result.WritingDirection, Is.EqualTo(WritingDirection.LeftToRight));
                         Assert.That(result.TextLineOrder, Is.EqualTo(TextLineOrder.TopToBottom));
                     }
                     // Not sure...
                 } while (pageLayout.Next(PageIteratorLevel.Block));
             }
         }
     }
 }
开发者ID:Picazsoo,项目名称:tesseract,代码行数:29,代码来源:AnalyseResultTests.cs

示例8: LoadTexture

        public void LoadTexture(string textureId, string path)
        {
            Debug.Assert(File.Exists(path));

            var id = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, id);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            var image = new Bitmap(path);
            var width = image.Width;
            var height = image.Height;

            image.RotateFlip(RotateFlipType.Rotate180FlipY);

            var data = image.LockBits(
                new Rectangle(0, 0, width, height),
                ImageLockMode.ReadOnly,
                DrawingPixelFormat.Format32bppArgb);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0,
                PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

            image.UnlockBits(data);

            _textureDatabase.Add(textureId, new Texture(id, width, height));
        }
开发者ID:deevus,项目名称:CSharpGameProgOpenTK,代码行数:28,代码来源:TextureManager.cs

示例9: Set

        internal void Set(Bitmap bitmap)
        {
            bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

            var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            GL.BindTexture(TextureTarget.Texture2D, tex);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                bitmap.Width, bitmap.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
            bitmap.UnlockBits(data);

            Width = bitmap.Width;
            Height = bitmap.Height;

            bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
        }
开发者ID:kuviman,项目名称:csVPE,代码行数:16,代码来源:SaveLoad.cs

示例10: Texture

        public Texture(string _mapPath, bool flipY = true)
        {
            using (Stream s = Interface.GetStreamFromPath (_mapPath)) {

                try {
                    Map = _mapPath;

                    Bitmap bitmap = new Bitmap (s);

                    if (flipY)
                        bitmap.RotateFlip (RotateFlipType.RotateNoneFlipY);

                    BitmapData data = bitmap.LockBits (new System.Drawing.Rectangle (0, 0, bitmap.Width, bitmap.Height),
                        ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    createTexture (data.Scan0, data.Width, data.Height);

                    bitmap.UnlockBits (data);

                    GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
                    GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

                    GL.GenerateMipmap (GenerateMipmapTarget.Texture2D);

                } catch (Exception ex) {
                    Debug.WriteLine ("Error loading texture: " + Map + ":" + ex.Message);
                }
            }
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:29,代码来源:Texture.cs

示例11: GetThumbnailInner

        protected override System.Drawing.Image GetThumbnailInner()
        {
            Bitmap result = new Bitmap( 80, 48, PixelFormat.Format32bppArgb );

            using( Bitmap portrait = new Bitmap( 48, 32, PixelFormat.Format8bppIndexed ) )
            {
                Bitmap wholeImage = ToBitmap();
                wholeImage.CopyRectangleToPointNonIndexed(
                    ThumbnailRectangle,
                    result,
                    new Point( ( 48 - ThumbnailRectangle.Width ) / 2, ( 48 - ThumbnailRectangle.Height ) / 2 ),
                    Palettes[0],
                    false );

                ColorPalette palette2 = portrait.Palette;
                Palette.FixupColorPalette( palette2, Palettes );
                portrait.Palette = palette2;
                wholeImage.CopyRectangleToPoint( PortraitRectangle, portrait, Point.Empty, Palettes[8], false );
                portrait.RotateFlip( RotateFlipType.Rotate270FlipNone );

                portrait.CopyRectangleToPointNonIndexed( new Rectangle( 0, 0, 32, 48 ), result, new Point( 48, 0 ), Palettes[8], false );
            }

            return result;
        }
开发者ID:Wi150nZ,项目名称:lioneditor,代码行数:25,代码来源:AbstractCompressedSprite.cs

示例12: DrawWheelBtnMouse

        private Bitmap DrawWheelBtnMouse(Size pictSize, bool icon)
        {
            double ration = icon ? 1.05 : 0.8;
            Bitmap bmp = new Bitmap(pictSize.Width, pictSize.Height);
            Graphics gp = Graphics.FromImage(bmp);
            gp.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
            int width = (int)Math.Min(bmp.Width * ration, bmp.Height * ration);
            if (width > Resources.base_mouse.Width)
                width = Resources.base_mouse.Width;
            int height = width;
            Point pos;
            if (icon)
                pos = new Point((bmp.Width - width) / 2, (bmp.Height - height) / 2);
            else
                pos = new Point((bmp.Width - width) / 2, (bmp.Height - height) / 4);
            Rectangle r = new Rectangle(pos, new Size(width, height));
            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);            
            gp.DrawImage(Resources.btn_middle_modifier, r.X, r.Y, r.Width, r.Height);
            DrawTrigger(m_trigger, gp, r);
            gp.DrawImage(Resources.btn_wheel_down, r.X, r.Y, r.Width, r.Height);
            gp.DrawImage(Resources.btn_wheel_up, r.X, r.Y, r.Width, r.Height);            
            gp.Dispose();

            // If buttons are swaped then flip the image
            bool swapedButtons = Win32.GetSystemMetrics(Win32.SM_SWAPBUTTON) == 0 ? false : true;
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);         
   
            return bmp;
        }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:29,代码来源:WheelButton.cs

示例13: AddFrame

        /// <summary>Adds a new frame to the AVI stream</summary>
        /// <param name="bmp">The image to add</param>
        public void AddFrame(Bitmap bmp, uint uiQuality, short shBitCount)
        {

            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);

            BitmapData bmpDat = bmp.LockBits(
                new Rectangle(0, 0, bmp.Width, bmp.Height),
                ImageLockMode.ReadOnly, PixelFormat.Format16bppArgb1555);

            if (countFrames == 0)
            {
                //this is the first frame - get size and create a new stream
                this.stride = (UInt32)bmpDat.Stride;
                this.width = bmp.Width;
                this.height = bmp.Height;
                CreateStream(uiQuality,shBitCount);
            }

            int result = Avi.AVIStreamWrite(aviStream,
                countFrames, 1,
                bmpDat.Scan0, //pointer to the beginning of the image data
                (Int32)(stride * height),
                0, 0, 0);

            if (result != 0)
            {
                throw new Exception("Error in AVIStreamWrite: " + result.ToString());
            }

            bmp.UnlockBits(bmpDat);
            countFrames++;
        }
开发者ID:Hagser,项目名称:csharp,代码行数:34,代码来源:AviWriter.cs

示例14: Histogram

        public void Histogram(Bitmap image)
        {
            Bitmap d = new Bitmap(256, 1025);
            int[] hist = new int[255];

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    int br = Convert.ToInt16(image.GetPixel(i, j).GetBrightness() * 50);
                    hist[br]++;
                }
            }

            for (int i = 0; i < 255; i++)
            {
                for (int j = 0; j < hist[i]; j++)
                {
                    d.SetPixel(i, j / 80, Color.Black);
                }
            }

            d.RotateFlip(RotateFlipType.Rotate180FlipNone);
            pictureBox2.Image = d;
        }
开发者ID:pkt-fit-knu,项目名称:I22-11,代码行数:25,代码来源:Form1.cs

示例15: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            // Release any previous buffer
            if (m_ip != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(m_ip);
                m_ip = IntPtr.Zero;
            }

            // capture image
            m_ip = capturer.Click();
            Bitmap b = new Bitmap(capturer.Width, capturer.Height, capturer.Stride, PixelFormat.Format24bppRgb, m_ip);

            // If the image is upsidedown
            b.RotateFlip(RotateFlipType.RotateNoneFlipY);
            capturer.Dispose();
            capturer = null;
            GC.Collect();

            image.Image = b;
            originalImage = (Image) image.Image.Clone();
            disableControl(false);
            button3.Visible = true;

            Cursor.Current = Cursors.Default;
        }
开发者ID:kukuhheru,项目名称:simpleposyandu,代码行数:28,代码来源:frmTakePhoto.cs


注:本文中的System.Drawing.Bitmap.RotateFlip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。