private void Start() { imageRotator = GetComponentInChildren <RotateImage>(); visability = true; rTransfrom = GetComponent <RectTransform>(); startPos = rTransfrom.anchoredPosition; }
public void TestRotateImage() { var arr = new int[3, 3] { { 1, 2, 3, }, { 4, 5, 6, }, { 7, 8, 9, }, }; RotateImage.Rotate(arr); Assert.AreEqual(arr[0, 0], 7); arr = new int[4, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 }, }; RotateImage.Rotate(arr); Assert.AreEqual(arr[2, 2], 7); Assert.AreEqual(arr[2, 3], 3); Assert.AreEqual(arr[3, 2], 8); Assert.AreEqual(arr[3, 3], 4); }
public ImageResult RotateImage(RotateImage rotate) { var result = new ImageResult { Message = OpMessage.Success }; try { if (rotate.Param.RotateLeft) { imageFactory.Rotate(270).Save(outStream); } if (rotate.Param.RotateRight) { imageFactory.Rotate(90).Save(outStream); } if (rotate.Param.RotateByDegrees != 0) { imageFactory.Rotate(rotate.Param.RotateByDegrees % 360).Save(outStream); } } catch (Exception ex) { result.Message = OpMessage.InvalidInputParameter; return(result); } result.Result = outStream.ToArray(); return(result); }
public void RotateImageFourByFourMatrixResultsInSuccess() { //arrange int[][] matrix = new int[][] { new int[] { 5, 1, 9, 11 }, new int[] { 2, 4, 8, 10 }, new int[] { 13, 3, 6, 7 }, new int[] { 15, 14, 12, 16 }, }; //arrange int[][] rotatedMatrix = new int[][] { new int[] { 15, 13, 2, 5 }, new int[] { 14, 3, 4, 1 }, new int[] { 12, 6, 8, 9 }, new int[] { 16, 7, 10, 11 }, }; var expectedResult = TraveseArray(rotatedMatrix); RotateImage.Rotate(matrix); var actualResult = TraveseArray(matrix); Assert.Equal(expectedResult, actualResult); }
public static void Main() { DisplayControl dc = new DisplayControl(); int height = dc.ShorterSide; int width = dc.LongerSide; int delayBetween = 1100; DisplayOrientation orientation = (DisplayOrientation)dc.Orientation; Bitmap fullScreenBitmap = new Bitmap(width, height); // Use this bitmap as our buffered output to the screen. fullScreenBitmap.Clear(); Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12); while (true) { RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); ColourGradient colourGradient = new ColourGradient(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); Colours ColourExample = new Colours(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); PagedText pt = new PagedText(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); BouncingBalls bb = new BouncingBalls(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); TileImage ti = new TileImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); FontExamples fe = new FontExamples(fullScreenBitmap); Thread.Sleep(delayBetween); RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); MatrixRain mr = new MatrixRain(fullScreenBitmap); Thread.Sleep(Timeout.Infinite); } }
public static void Main() { int delayBetween = 1100; // Get full screen bitmap from displayControl to draw on. Bitmap fullScreenBitmap = DisplayControl.FullScreen; fullScreenBitmap.Clear(); Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12); while (true) { RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); ColourGradient colourGradient = new ColourGradient(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); Colours ColourExample = new Colours(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); PagedText pt = new PagedText(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); BouncingBalls bb = new BouncingBalls(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); TileImage ti = new TileImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); FontExamples fe = new FontExamples(fullScreenBitmap); Thread.Sleep(delayBetween); RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); MatrixRain mr = new MatrixRain(fullScreenBitmap); Thread.Sleep(Timeout.Infinite); } }
public void Test2() { var input = new[] { new[] { 1 } }; var result = RotateImage.rotateImage(input); var expectedResult = new[] { new[] { 1 } }; CollectionAssert.AreEqual(expectedResult, result, new CollectionAssertComperator()); }
public void TestRotateImage() { var imageRotater = new RotateImage(); //var matrix1 = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; //imageRotater.Rotate(matrix1); var matrix = new int[, ] { { 5, 1, 9, 11 }, { 2, 4, 8, 10 }, { 13, 3, 6, 7 }, { 15, 14, 12, 16 } }; imageRotater.Rotate(matrix); }
void InternalTest(int[][] matrix, int[][] expected) { RotateImage.Rotate(matrix); for (int x = 0; x < matrix.GetLength(0); x++) { for (int y = 0; y < matrix[x].GetLength(0); y++) { Assert.Equal <int>(expected[x][y], matrix[x][y]); } } }
public static void Main() { DisplayControl dc = new DisplayControl(); int height = dc.ShorterSide; int width = dc.LongerSide; int bpp = dc.BitsPerPixel; int delayBetween = 3000; Bitmap fullScreenBitmap = new Bitmap(width, height); // Use this bitmap as our output to the screen. fullScreenBitmap.Clear(); fullScreenBitmap.Flush(); DisplayOrientation orientation = (DisplayOrientation)dc.Orientation; Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12); while (true) { SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); FontExamples fe = new FontExamples(fullScreenBitmap); Thread.Sleep(delayBetween); StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); TileImage ti = new TileImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomEllipses re = new RandomEllipses(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); MatrixRain mr = new MatrixRain(fullScreenBitmap, DisplayFont); Thread.Sleep(Timeout.Infinite); } }
public void rotateImageTest() { var r = new RotateImage(); Func <string, int> parse = int.Parse; var matrix = Util.ParseJaggedArray(@"[[1,2,3], [4,5,6], [7,8,9]]", parse); var expected = "[[7,4,1],[8,5,2],[9,6,3]]"; Assert.AreEqual(expected, Util.JaggedArrayToString(r.rotateImage(matrix))); matrix = Util.ParseJaggedArray(@"[[1]]", parse); expected = "[[1]]"; Assert.AreEqual(expected, Util.JaggedArrayToString(r.rotateImage(matrix))); matrix = Util.ParseJaggedArray(@"[[10,9,6,3,7], [6,10,2,9,7], [7,6,3,8,2], [8,9,7,9,9], [6,8,6,8,2]]", parse); expected = "[[6,8,7,6,10],[8,9,6,10,9],[6,7,3,2,6],[8,9,8,9,3],[2,9,2,7,7]]"; Assert.AreEqual(expected, Util.JaggedArrayToString(r.rotateImage(matrix))); matrix = Util.ParseJaggedArray(@"[[40,12,15,37,33,11,45,13,25,3], [37,35,15,43,23,12,22,29,46,43], [44,19,15,12,30,2,45,7,47,6], [48,4,40,10,16,22,18,36,27,48], [45,17,36,28,47,46,8,4,17,3], [14,9,33,1,6,31,7,38,25,17], [31,9,17,11,29,42,38,10,48,6], [12,13,42,3,47,24,28,22,3,47], [38,23,26,3,23,27,14,40,15,22], [8,46,20,21,35,4,36,18,32,3]]", parse); expected = "[[8,38,12,31,14,45,48,44,37,40],[46,23,13,9,9,17,4,19,35,12],[20,26,42,17,33,36,40,15,15,15],[21,3,3,11,1,28,10,12,43,37],[35,23,47,29,6,47,16,30,23,33],[4,27,24,42,31,46,22,2,12,11],[36,14,28,38,7,8,18,45,22,45],[18,40,22,10,38,4,36,7,29,13],[32,15,3,48,25,17,27,47,46,25],[3,22,47,6,17,3,48,6,43,3]]"; Assert.AreEqual(expected, Util.JaggedArrayToString(r.rotateImage(matrix))); matrix = Util.ParseJaggedArray(@"[[33,35,8,24,19,1,3,1,4,5], [25,27,40,25,17,35,20,3,19,3], [9,1,9,30,9,25,32,12,15,22], [30,47,25,10,18,1,19,17,43,17], [40,46,42,34,18,48,29,40,31,39], [37,42,37,19,45,1,4,46,48,13], [8,26,31,46,44,24,34,29,12,25], [45,48,36,12,33,12,4,45,22,37], [33,15,34,25,34,8,50,48,30,28], [18,19,22,29,15,43,38,30,8,47]]", parse); expected = "[[18,33,45,8,37,40,30,9,25,33],[19,15,48,26,42,46,47,1,27,35],[22,34,36,31,37,42,25,9,40,8],[29,25,12,46,19,34,10,30,25,24],[15,34,33,44,45,18,18,9,17,19],[43,8,12,24,1,48,1,25,35,1],[38,50,4,34,4,29,19,32,20,3],[30,48,45,29,46,40,17,12,3,1],[8,30,22,12,48,31,43,15,19,4],[47,28,37,25,13,39,17,22,3,5]]"; Assert.AreEqual(expected, Util.JaggedArrayToString(r.rotateImage(matrix))); }
public void Test1() { var input = new[] { new[] { 1, 2, 3 }, new[] { 4, 5, 6 }, new[] { 7, 8, 9 } }; var result = RotateImage.rotateImage(input); var expectedResult = new[] { new[] { 7, 4, 1 }, new[] { 8, 5, 2 }, new[] { 9, 6, 3 } }; CollectionAssert.AreEqual(expectedResult, result, new CollectionAssertComperator()); }
/// <summary> /// process rotate image request /// </summary> private string rotateImage(string imageFile, bool rotateLeft, bool rotateRight) { iRotateImage rotateImage = new RotateImage(); if (rotateLeft) { return(rotateImage.RotateImageLeft(imageFile)); } else if (rotateRight) { return(rotateImage.RotateImageRight(imageFile)); } else { return(null); } }
public void Test01() { var instance = new RotateImage(); var image = new[, ] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; var rotated = new int[, ] { { 7, 4, 1 }, { 8, 5, 2 }, { 9, 6, 3 } }; var rotatedImage = instance.Rotate(image); //Assert.AreEqual(rotated, rotatedImage); }
public void Test3() { var input = new[] { new[] { 10, 9, 6, 3, 7 }, new[] { 6, 10, 2, 9, 7 }, new[] { 7, 6, 3, 8, 2 }, new[] { 8, 9, 7, 9, 9 }, new[] { 6, 8, 6, 8, 2 }, }; var result = RotateImage.rotateImage(input); var expectedResult = new[] { new[] { 6, 8, 7, 6, 10 }, new[] { 8, 9, 6, 10, 9 }, new[] { 6, 7, 3, 2, 6 }, new[] { 8, 9, 8, 9, 3 }, new[] { 2, 9, 2, 7, 7 }, }; CollectionAssert.AreEqual(expectedResult, result, new CollectionAssertComperator()); }
static void Main(string[] args) { Console.WriteLine(String.Format("Has all unique characters for {0}? The answer is: {1}", "mondaym", HasAllUniqueCharacters.HasAllUniqueCharatersWithDS("mondaym"))); ReverseString.reverse("thisiscorrect"); Console.WriteLine(String.Format("{0} is permutation of {1}: {2}", "danliu", "uinlda", StringPermutation.IsPermutation("danliu", "uinlda"))); Console.WriteLine(String.Format("{0} is permutation of {1}: {2}", "danliu", "sophia", StringPermutation.IsPermutation("danliu", "sophia"))); ReplacWhiteSpaceWith20Percent.ReplaceWhiteSpaceWith20("Mr. John Smith"); StringCompression.CompressString("aabcccccaaa"); StringCompression.CompressString("abcdefgg"); int[,] imageOrignal = new int[2, 2] { { 1, 2 }, { 3, 4 } }; RotateImage.Rotate(imageOrignal); int[,] m1 = new int[3, 3] { { 1, 2, 5 }, { 3, 1, 0 }, { 0, 4, 7 } }; SetZeroToMatrix.SetZeroToRowAndColumn(m1); Console.WriteLine(WordRotation.IsWordRotation("erbottlewat", "Waterbottle")); Console.WriteLine(WordRotation.IsWordRotation("Waterbottle", "erbettoewti")); }
public IActionResult RotateImage([FromBody] RotateImage inputs) { ImageProHandler.LoadImage(inputs.Imagestream); var response = ImageProHandler.RotateImage(inputs); ImageProHandler.outStream.Close(); ImageProHandler.inStream.Close(); if (response.Message == OpMessage.InvalidOperation) { return(StatusCode(405, new InvalidOperationError() { })); } else if (response.Message == OpMessage.InvalidInputParameter) { return(StatusCode(409, new InvalidInputParameterError() { })); } return(Ok(response)); }
public void Rotate1RowBy90degrees() { int[,] inputMatrix = new int[, ] { { 1, 2, 3 }, { 0, 0, 0 }, { 0, 0, 0 } }; int[,] rotateMatrix = new int[, ] { { 0, 0, 1 }, { 0, 0, 2 }, { 0, 0, 3 } }; RotateImage rotateImage = new RotateImage(); rotateImage.Rotate(ref inputMatrix); CollectionAssert.AreEqual(rotateMatrix, inputMatrix); }
public void Rotate3RowBy90degrees() { int[,] inputMatrix = new int[, ] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; int[,] rotateMatrix = new int[, ] { { 7, 4, 1 }, { 8, 5, 2 }, { 9, 6, 3 } }; RotateImage rotateImage = new RotateImage(); rotateImage.Rotate(ref inputMatrix); CollectionAssert.AreEqual(rotateMatrix, inputMatrix); }
public ImageResult MultipleOperation(MultiOperation inputs) { var result = new ImageResult { Message = OpMessage.Success }; var param = inputs.MultiOperationParam; var flipOps = param.FlipParam; var gsOps = param.GreyScaleParam; var resizeOps = param.ResizeParam; var rotateOps = param.RotateParam; var thumbnailOps = param.ThumbnailParam; var allOps = flipOps.Count() + gsOps.Count() + resizeOps.Count() + rotateOps.Count() + thumbnailOps.Count(); if (allOps != param.MultiOperationSequence.Count() || param.MultiOperationSequence.Count() == 0) { result.Message = OpMessage.InvalidInputParameter; return(result); } try { param.MultiOperationSequence.ForEach(operation => { switch (operation) { case Operations.FLIP: var flipParam = flipOps[0]; flipOps.Remove(flipParam); var fp = new FlipImage { Param = flipParam, }; FlipImage(fp); break; case Operations.ROTATE: var rotateParam = rotateOps[0]; rotateOps.Remove(rotateParam); var rop = new RotateImage { Param = rotateParam, }; RotateImage(rop); break; case Operations.RESIZE: var resizeParam = resizeOps[0]; resizeOps.Remove(resizeParam); var rep = new ResizeImage { Param = resizeParam, }; ResizeImage(rep); break; case Operations.GRAYSCALE: var gsParam = gsOps[0]; gsOps.Remove(gsParam); GrayScaleImage(); break; case Operations.THUMBNAIL: var tp = thumbnailOps[0]; thumbnailOps.Remove(tp); ThumbnailImage(); break; default: throw new Exception(); } imageFactory.Load(outStream); }); } catch (Exception ex) { result.Message = OpMessage.InvalidOperation; return(result); } result.Result = outStream.ToArray(); return(result); }
public static void Main() { int delayBetween = 1100; #if ESP32 // This is an example mapping, work them out for your needs! int backLightPin = 32; int chipSelect = 14; int dataCommand = 27; int reset = 33; // Add the nanoFramework.Hardware.Esp32 to the solution Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO); Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI); Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK); // Adjust as well the size of your screen and the position of the screen on the driver DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(0, 0, 320, 240)); // Depending on you ESP32, you may also have to use either PWM either GPIO to set the backlight pin mode on // GpioController.OpenPin(backLightPin, PinMode.Output); // GpioController.Write(backLightPin, PinValue.High); #elif STM32F769I_DISCO // This is an example (working) button map, work the actual pins out for your need! //WARNING: Invalid pin mappings will never be returned, and may need you to reflash the device! DisplayControl.Initialize(new SpiConfiguration(), new ScreenConfiguration()); #else throw new System.Exception("Unknown display mapping!"); #endif // Get full screen bitmap from displayControl to draw on. Bitmap fullScreenBitmap = DisplayControl.FullScreen; fullScreenBitmap.Clear(); Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12); while (true) { RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); ColourGradient colourGradient = new ColourGradient(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); Colours ColourExample = new Colours(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); PagedText pt = new PagedText(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); BouncingBalls bb = new BouncingBalls(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); TileImage ti = new TileImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); FontExamples fe = new FontExamples(fullScreenBitmap); Thread.Sleep(delayBetween); RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont); Thread.Sleep(delayBetween); MatrixRain mr = new MatrixRain(fullScreenBitmap); Thread.Sleep(Timeout.Infinite); } }
public void TestMethod1() { var rotateImage = new RotateImage(); }
public void MakeInstance() { RotateImage rotateImage = new RotateImage(); }
private void RandomizeImage(object sender, MouseEventArgs e) { Bitmap randomImage = RotateImage.MakeRandomImage((Bitmap)RotateImage.myPictureBox.Image); RotateImage.myPictureBox.Image = randomImage; }
private void MainMenu_Load(object sender, EventArgs e) { sideMenu = new SideMenu(this, true); RotateImage.Test(this); this.MouseWheel += RandomizeImage; }
public void RotateTests() { RotateImage obj = new RotateImage(); int[][] arr = new int[][] { new[] { 1, 2, 3 }, new[] { 4, 5, 6 }, new[] { 7, 8, 9 } }; //[7,4,1], //[8,5,2], //[9,6,3] obj.Rotate(arr); arr = new int[][] { new[] { 5, 1, 9, 11 }, new[] { 2, 4, 8, 10 }, new[] { 13, 3, 6, 7 }, new[] { 15, 14, 12, 16 } }; //[15,13, 2, 5], //[14, 3, 4, 1], //[12, 6, 8, 9], //[16, 7,10,11] obj.Rotate(arr); arr = new int[][] { new[] { 1, 2, 3, 4 }, new[] { 5, 6, 7, 8 }, new[] { 9, 10, 11, 12 }, new[] { 13, 14, 15, 16 } }; obj.Rotate(arr); arr = new int[][] { new[] { 1, 2, 3, 4 }, new[] { 5, 6, 7, 8 }, new[] { 9, 10, 11, 12 }, new[] { 13, 14, 15, 16 } }; obj.Rotate(arr); arr = new int[][] { }; obj.Rotate(arr); arr = new int[][] { new[] { 1 } }; obj.Rotate(arr); arr = new int[][] { new[] { 1, 2 }, new[] { 3, 4 } }; obj.Rotate(arr); }