Exemplo n.º 1
0
        public static Bitmap RecognizeDocumentInImage(Bitmap originalBmp)
        {
            var grayscale      = new GrayscaleImage(originalBmp);
            var compressionBmp = BitmapProcessing.ImageCompression(originalBmp);
            var processedImage = ImageFilters.ImageFiltering(compressionBmp);
            var resultSearch   = SearchSingularPoints.SerchSPForImage(originalBmp, compressionBmp, processedImage);

            var spPoints  = resultSearch.Item1;
            var equations = resultSearch.Item2;

            BitmapProcessing.SelectBackground(grayscale, equations);

            var widthAndHeight = MakeWidthAndHeightDocument(spPoints);
            var documentWidth  = widthAndHeight.Item1;
            var documentHeight = widthAndHeight.Item2;

            var anglePoints = MakeAnglePoints(documentWidth, documentHeight, spPoints);
            var H           = GetMatrixHomography(spPoints, anglePoints);
            var inverseH    = H.Inverse();

            var correctImage     = ImageCorrection(inverseH, grayscale);
            var correctSpPoints  = TransformPoints(inverseH, spPoints);
            var correctEquations = MakeEquationsLines(correctSpPoints);
            var angle            = correctEquations[2].AngleDeviationOX();

            correctImage = BitmapProcessing.RotateGrayscaleImage(correctImage, angle);
            var document = ImageCutter.CutDocument(correctImage);

            return(BitmapProcessing.MakeBitmap(document.Width, document.Height, document.Colors));
            //return BitmapProcessing.MakeBitmap(correctImage.Width, correctImage.Height, correctImage.Colors);
        }
Exemplo n.º 2
0
        public ActionResult submit()
        {
            clearTempLocal();

            var       httpRequest = Request.Form;
            var       files       = httpRequest.Files;
            Selection selection   = JsonConvert.DeserializeObject <Selection>(httpRequest["selection"]);
            int       i           = 0;

            try
            {
                foreach (Image img in ImageCutter.processFiles(files, selection))
                {
                    img.Save(tempPath + "/Out/file" + i + ".png", ImageFormat.Png);
                    i++;
                }
            }
            catch (Exception e)
            {
                return(new JsonResult(e));
            }

            string resultpath = this.tempPath + "/results.zip";

            System.IO.File.Delete(resultpath);
            ZipFile.CreateFromDirectory(this.tempPath + "/Out", resultpath);
            return(PhysicalFile(resultpath, "application/zip", "result.zip"));
        }
Exemplo n.º 3
0
    void OnSelectConfirm(Vector2 pos, int width)
    {
        Vector2   realPos    = ((pos - new Vector2(width / 2, width / 2)) + new Vector2(finalBoxWidth / 2, finalBoxHeight / 2)) / scale;
        int       realWidth  = (int)(width / scale);
        Texture2D newTexture = ImageCutter.CutTexture(image.texture as Texture2D, realPos, realWidth, realWidth);

        finalTexture          = newTexture;
        showImage_100.texture = newTexture;
        showImage_50.texture  = newTexture;
    }
Exemplo n.º 4
0
 public CardBox(Card card) : base()
 {
     this.card     = card;
     base.Image    = ImageCutter.GetBackImage();
     base.Location = new System.Drawing.Point(100, 0);
     //base.Name = "cardBox0";
     //base.Size = new System.Drawing.Size(86, 126);
     base.Size     = new System.Drawing.Size(57, 84);
     base.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
     base.TabIndex = 1;
     base.TabStop  = false;
     //base.Click += new System.EventHandler(this.pictureBox1_Click);
 }
Exemplo n.º 5
0
        public void Generate()
        {
            try
            {
                Console.WriteLine("Generating the map image...");

                Console.WriteLine("World Path: " + World.WorldPath);

                WorldMapper mapper = new WorldMapper();
                mapper.Initialize();
                mapper.OpenWorld();

                if (!Directory.Exists(OutputFolder))
                {
                    Directory.CreateDirectory(OutputFolder);
                }

                string path = Path.Combine(OutputFolder, MapFileName);

                mapper.ProcessWorld(World.WorldPath, null);
                mapper.CreatePreviewPNG(path, null);
                ImageCutter cutter = new ImageCutter(path, Path.Combine(OutputFolder, CutsFolder));

                cutter.Cuts();
                //Generating the map info

                MapStaticInfo msi = new MapStaticInfo();

                msi.Cols      = cutter.Cols;
                msi.Rows      = cutter.Rows;
                msi.WorldName = World.WorldName;

                File.WriteAllText(Path.Combine(OutputFolder, CutsFolder, MapInfoFile), msi.ToString());
                File.WriteAllText(Path.Combine(OutputFolder, CutsFolder, StampFile), msi.Generated.ToString());
                Console.WriteLine("Map image generated!");
                //Release thread ref
                thread = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while generating the image map");
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.Message);
                //thread.Abort();
                thread = null;
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            //paste output here https://jsfiddle.net/npc2410s/3/
            //vairables
            double lat = 43.80022782085926;
            double lon = -79.46874957722167;
            //cute the image into peices
            ImageCutter cutter = new ImageCutter(@"bulbasaur.png", 16, 16);
            //draw the sprite on a map
            DrawSprite ds = new DrawSprite(cutter.CutImages, cutter.Width, cutter.Height, lat, lon);

            //print it out
            File.Delete("out.txt");
            File.Delete("DrawImg.csv");
            using (StreamWriter sw = new StreamWriter(@"OutPutForFiddle.txt", false))
            {
                using (StreamWriter sw2 = new StreamWriter(@"ImageCrds.csv", false))
                {
                    //write the js code for fiddle test
                    sw.Write("function initMap(){var myLatLng = {lat: 43.8041958395909,lng: -79.754306699939};var map = new google.maps.Map(document.getElementById('map'), {zoom: 10,center: myLatLng});");

                    Random r = new Random();
                    foreach (Square currS in ds.Mover.SquareList)
                    {
                        currS.FixSquare();

                        if (currS.Live == true)
                        {
                            //write out the cords for mapping software as csv
                            sw2.WriteLine(String.Format(@"{0},{1},{2},{3}", currS.A.X, currS.A.Y, currS.B.X, currS.B.Y));
                            //write the js code for fiddle test
                            sw.WriteLine(GetCordString(currS.A.Latitude.ToString(), currS.A.Longitude.ToString(), r.Next(5000).ToString()));
                            sw.WriteLine(GetCordString(currS.B.Latitude.ToString(), currS.B.Longitude.ToString(), r.Next(5000).ToString()));
                            sw.WriteLine(GetCordString(currS.AB.Latitude.ToString(), currS.AB.Longitude.ToString(), r.Next(5000).ToString()));
                            sw.WriteLine(GetCordString(currS.BA.Latitude.ToString(), currS.BA.Longitude.ToString(), r.Next(5000).ToString()));
                        }
                    }
                    //write the js code for fiddle test
                    sw.Write("}");
                    sw.Close();
                    sw2.Close();
                }
            }
            Console.Read();
        }
Exemplo n.º 7
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        ImageCutter image = (ImageCutter)target;

        if (GUILayout.Button("SpawnGO"))
        {
            image.SpawnGObj();
        }
        if (GUILayout.Button("Delete"))
        {
            image.RemoveAllGObj();
        }
        if (GUILayout.Button("Save Prefab"))
        {
            image.SaveSelectedAsPrefab();
        }
    }
Exemplo n.º 8
0
 public void SetUp()
 {
     cutter = new ImageCutter();
 }
Exemplo n.º 9
0
        private static async Task <int> Main(string[] args)
        {
            FileSystemRepository shapeSetsFileSysRepo        = new FileSystemRepository(ShapeSetsDirectory);
            FileSystemRepository legacyShapeSetsFileSysRepo  = new FileSystemRepository(LegacyShapeSetsDirectory);
            FileSystemRepository survivalCraftingFileSysRepo = new FileSystemRepository(SurvivalCraftingDirectory);
            FileSystemRepository characterFileSysRepo        = new FileSystemRepository(CharacterDirectory);
            FileSystemRepository legacyLanguageFileSysRepo   = new FileSystemRepository(LegacyLanguageDirectory);
            FileSystemRepository survivalLanguageFileSysRepo = new FileSystemRepository(SurvivalLanguageDirectory);
            FileSystemRepository attackFileSysRepo           = new FileSystemRepository(AttackDataDirectory);

            FileSystemRepository outputFileSysRepo = new FileSystemRepository(OutputDirectory);
            FileSystemRepository inputFileSysRepo  = new FileSystemRepository(InputDirectory);
            FileSystemRepository appFilesSysRepo   = new FileSystemRepository(AppJsonFilesDirectory);
            FileSystemRepository appImagesRepo     = new FileSystemRepository(AppImagesDirectory);
            FileSystemRepository appDataSysRepo    = new FileSystemRepository(AppDataDirectory);
            FileSystemRepository appLangSysRepo    = new FileSystemRepository(AppLangDirectory);

            LanguageDetail language = new LanguageDetail(LanguageType.English, "English", "en");

            Console.WriteLine("Hit Enter");
            Console.ReadLine();
            int langCount = 0;

            Console.WriteLine("Please select an option");
            foreach (LanguageType langType in AvailableLangs)
            {
                if (langType == LanguageType.NotSpecified)
                {
                    continue;
                }
                langCount++;
                Console.WriteLine($"{langCount}. Localise Files to {langType}");
            }
            Console.WriteLine($"{AvailableLangs.Length}. Generate All Files for All Languages");

            string langInput = Console.ReadLine();

            if (!int.TryParse(langInput, out int langNumberInput))
            {
                return(0);
            }
            if (langNumberInput < 0 || langNumberInput > AvailableLangs.Length)
            {
                return(0);
            }

            if (langNumberInput != 0 && langNumberInput < AvailableLangs.Length)
            {
                LanguageType selectedLangType = AvailableLangs[langNumberInput];
                language = LanguageHelper.GetLanguageDetail(selectedLangType);
            }

            FileHandlers.GameFilesReader gameFilesReader = new FileHandlers.GameFilesReader(outputFileSysRepo,
                                                                                            shapeSetsFileSysRepo, legacyShapeSetsFileSysRepo,
                                                                                            survivalCraftingFileSysRepo, characterFileSysRepo,
                                                                                            legacyLanguageFileSysRepo, survivalLanguageFileSysRepo);

            if (langNumberInput != 0 && langNumberInput == AvailableLangs.Length)
            {
                List <string> completedFolders = new List <string>();
                foreach (LanguageType langType in AvailableLangs)
                {
                    language = LanguageHelper.GetLanguageDetail(langType);
                    if (completedFolders.Contains(language.LanguageAppFolder))
                    {
                        continue;
                    }

                    GenerateAppFiles(gameFilesReader, outputFileSysRepo, appFilesSysRepo, appImagesRepo, language);
                    completedFolders.Add(language.LanguageAppFolder);
                }

                return(0);
            }

            while (true)
            {
                Console.WriteLine("Please select an option:");
                Console.WriteLine("0. Exit");
                Console.WriteLine("1. Generate Intermediate Files");
                Console.WriteLine($"2. Create App Files in {language.LanguageGameFolder}");
                Console.WriteLine("3. Cut images from sprite map");
                Console.WriteLine("4. Generate App Data files");
                Console.WriteLine("5. Write server data to app files");
                Console.WriteLine("6. Add item to Language Pack");

                string input = Console.ReadLine();
                if (!int.TryParse(input, out int numberInput))
                {
                    return(0);
                }

                DataFileHandler dataFileHandler = new DataFileHandler(inputFileSysRepo, appDataSysRepo, attackFileSysRepo, appLangSysRepo);

                switch (numberInput)
                {
                case 1:
                    gameFilesReader.GenerateIntermediate();
                    break;

                case 2:
                    GenerateAppFiles(gameFilesReader, outputFileSysRepo, appFilesSysRepo, appImagesRepo, language);
                    break;

                case 3:
                    Dictionary <string, List <ILocalised> > keyValueOfGameItems = gameFilesReader.GetKeyValueOfAllItems(includeOtherItems: true);

                    ImageCutter imageCutter = new ImageCutter(DataGuiDirectory, SurvivalGuiDirectory, OutputDirectory);
                    imageCutter.CutOutImages(keyValueOfGameItems);
                    break;

                case 4:
                    List <GameItemLocalised> gameItemsList = gameFilesReader.GetAllLocalisedGameItems(includeOtherItems: true);
                    dataFileHandler.GenerateDataFiles(gameItemsList);
                    break;

                case 5:
                    await WriteServerDataToAppFiles(dataFileHandler);

                    break;

                case 6:
                    AddItemToLanguagePacks();
                    break;

                default:
                    return(0);
                }
                Console.WriteLine("- - - - - - - - - - - -");
            }
        }