예제 #1
0
        public static RotateFlipType GetFlipTypeRotatedCW(RotateFlipType currentRotation)
        {
            RotateFlipType newRotation;

            switch (currentRotation)
            {
            case RotateFlipType.RotateNoneFlipNone:
                newRotation = RotateFlipType.Rotate90FlipNone;
                break;

            case RotateFlipType.Rotate90FlipNone:
                newRotation = RotateFlipType.Rotate180FlipNone;
                break;

            case RotateFlipType.Rotate180FlipNone:
            case RotateFlipType.RotateNoneFlipY:     // legacy images
                newRotation = RotateFlipType.Rotate270FlipNone;
                break;

            case RotateFlipType.Rotate270FlipNone:
                newRotation = RotateFlipType.RotateNoneFlipNone;
                break;

            default:
                Debug.Fail("Unknown RotateFlipType encountered: " + currentRotation.ToString());
                newRotation = RotateFlipType.RotateNoneFlipNone;
                break;
            }
            return(newRotation);
        }
 public static RotateFlipType GetFlipTypeRotatedCW(RotateFlipType currentRotation)
 {
     RotateFlipType newRotation;
     switch (currentRotation)
     {
         case RotateFlipType.RotateNoneFlipNone:
             newRotation = RotateFlipType.Rotate90FlipNone;
             break;
         case RotateFlipType.Rotate90FlipNone:
             newRotation = RotateFlipType.Rotate180FlipNone;
             break;
         case RotateFlipType.Rotate180FlipNone:
         case RotateFlipType.RotateNoneFlipY: // legacy images
             newRotation = RotateFlipType.Rotate270FlipNone;
             break;
         case RotateFlipType.Rotate270FlipNone:
             newRotation = RotateFlipType.RotateNoneFlipNone;
             break;
         default:
             Debug.Fail("Unknown RotateFlipType encountered: " + currentRotation.ToString());
             newRotation = RotateFlipType.RotateNoneFlipNone;
             break;
     }
     return newRotation;
 }
예제 #3
0
        private static void TestHalfArea(string testObject, Bitmap bitmap, RotateFlipType rft, int scale)
        {
            int xSize = Math.Max(bitmap.Width, bitmap.Height) * scale;
            int ySize = xSize;

            OutlineShape actual = SWA_Ariadne_Outlines_TilesOutlineShapeAccessor.FromBitmap(xSize, ySize, bitmap, rft, scale);

            Assert.AreEqual(xSize * ySize / 2, actual.Area, testObject + " " + rft.ToString() + ": incorrect Area");
        }
예제 #4
0
        /// <summary>
        /// Builds a pattern from the given bitmap, rotated and scaled.
        /// </summary>
        /// <param name="xSize"></param>
        /// <param name="ySize"></param>
        /// <param name="bitmap"></param>
        /// <param name="rft"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        private static OutlineShape FromBitmap(int xSize, int ySize, Bitmap bitmap, RotateFlipType rft, int scale)
        {
#if false
            System.Console.Out.WriteLine("[TilesOutlineShape.FromBitmap] " + rft.ToString() + ", x" + scale.ToString());
#endif

#if false
            // Note: Some bitmaps are useless (all black or all white) after the RotateFlip() operation!
            Bitmap template = (Bitmap)bitmap.Clone();
            template.RotateFlip(rft);
            TilesOutlineShape result = new TilesOutlineShape(xSize, ySize, template);
#else
            OutlineShape      tile   = new ExplicitOutlineShape(bitmap).RotatedOrFlipped(rft);
            TilesOutlineShape result = new TilesOutlineShape(xSize, ySize, tile as ExplicitOutlineShape);
#endif
            result.SetRepetitions(scale);

            return(result);
        }
예제 #5
0
파일: PolygonMath.cs 프로젝트: hwebz/NTCWeb
 public static RotateFlipType CombineFlipAndRotate(RotateFlipType flip, double angle)
 {
     if (flip != (RotateFlipType)FlipMode.None &&
         flip != (RotateFlipType)FlipMode.X &&
         flip != (RotateFlipType)FlipMode.Y &&
         flip != (RotateFlipType)FlipMode.XY)
     {
         throw new ArgumentException("Valid flip values are RotateNoneFlipNone, RotateNoneFlipX, RotateNoneFlipY, and RotateNoneFlipXY. Rotation must be specified with Rotate or srcRotate instead. Received: " + flip.ToString());
     }
     return(CombineFlipAndRotate((FlipMode)flip, angle));
 }
예제 #6
0
파일: test.cs 프로젝트: wateras/winforms
    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!");
    }
예제 #7
0
 public static RotateFlipType CombineFlipAndRotate(RotateFlipType flip, double angle)
 {
     if (flip != (RotateFlipType)FlipMode.None &&
         flip != (RotateFlipType)FlipMode.X &&
         flip != (RotateFlipType)FlipMode.Y &&
         flip != (RotateFlipType)FlipMode.XY)
         throw new ArgumentException("Valid flip values are RotateNoneFlipNone, RotateNoneFlipX, RotateNoneFlipY, and RotateNoneFlipXY. Rotation must be specified with Rotate or srcRotate instead. Received: " + flip.ToString());
     return CombineFlipAndRotate((FlipMode)flip, angle);
 }
예제 #8
0
 public override string GetShortDescription()
 {
     return(RotateFlipType.ToString());
 }
예제 #9
0
파일: Utils.cs 프로젝트: timgaunt/resizer
        /// <summary>
        /// Throws an exception if the specified value is unsupported. Rotation values are not supported, and should be specified with the Rotate or srcRotate command.
        /// </summary>
        /// <returns></returns>
        public static string writeFlip(RotateFlipType flip)
        {
            if (flip == RotateFlipType.RotateNoneFlipNone)
            {
                return("none");
            }
            if (flip == RotateFlipType.RotateNoneFlipX)
            {
                return("x");
            }
            if (flip == RotateFlipType.RotateNoneFlipY)
            {
                return("y");
            }
            if (flip == RotateFlipType.RotateNoneFlipXY)
            {
                return("xy");
            }

            throw new ArgumentException("Valid flip values are RotateNoneFlipNone, RotateNoneFlipX, RotateNoneFlipY, and RotateNoneFlipXY. Rotation must be specified with Rotate or srcRotate instead. Received: " + flip.ToString());
        }
예제 #10
0
    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("1bit.png");
                result.RotateFlip(type);
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}: {1}", e.GetType().Name, e.Message);
                if (result != null)
                {
                    try { result.Dispose(); } catch {}
                }
                result = null;
            }

            if (result != null)
            {
                result.Save("1bit_" + type_name + ".png", ImageFormat.Png);
            }

            try { result.Dispose(); } catch {}

            try
            {
                result = load("4bit.png");
                result.RotateFlip(type);
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: {0}: {1}", e.GetType().Name, e.Message);
                if (result != null)
                {
                    try { result.Dispose(); } catch {}
                }
                result = null;
            }

            if (result != null)
            {
                result.Save("4bit_" + type_name + ".png", ImageFormat.Png);
            }

            try { result.Dispose(); } catch {}
        }

        Console.WriteLine("done!");
    }