Esempio n. 1
0
        public static void Mirror(Bitmap img, MirrorOption side)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = MirrorHelper(img, side);

            int index = 0;

            foreach (var n in Enum.GetValues(typeof(MirrorOption)).Cast <MirrorOption>())
            {
                if (n == side)
                {
                    index = (int)n; break;
                }
                ;
            }

            string outName = defPath + imgName + MirrorVariant.ElementAt(index) + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Esempio n. 2
0
        private static Bitmap MirrorHelper(Bitmap img, MirrorOption side)
        {
            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            double Depth = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat);

            List <ArraysListInt> ColorList = Helpers.GetPixels(img);

            int[,] resultR = new int[img.Height, img.Width];
            int[,] resultG = new int[img.Height, img.Width];
            int[,] resultB = new int[img.Height, img.Width];

            PadMyArray <int> padArr = new PadMyArray <int>();

            if (side == MirrorOption.left || side == MirrorOption.right)
            {
                resultR = padArr.PadArray(ColorList[0].Color, 0, img.Width, PadType.symmetric, Direction.pre);
                resultG = padArr.PadArray(ColorList[1].Color, 0, img.Width, PadType.symmetric, Direction.pre);
                resultB = padArr.PadArray(ColorList[2].Color, 0, img.Width, PadType.symmetric, Direction.pre);
            }
            else
            {
                resultR = padArr.PadArray(ColorList[0].Color, img.Height, 0, PadType.symmetric, Direction.pre);
                resultG = padArr.PadArray(ColorList[1].Color, img.Height, 0, PadType.symmetric, Direction.pre);
                resultB = padArr.PadArray(ColorList[2].Color, img.Height, 0, PadType.symmetric, Direction.pre);
            }

            image = Helpers.SetPixels(image, resultR, resultG, resultB);

            if (Depth == 8)
            {
                image = PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(image);
            }
            else if (Depth == 1)
            {
                image = PixelFormatWorks.ImageTo1BppBitmap(image);
            }

            return(image);
        }
Esempio n. 3
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_srcPath == null)
            {
                return;
            }

            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("Mirror Directory: Mirror source directory to destination. This node does not use assets passed by.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_srcPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Mirror Directory Settings", node, true)){
                        if (enabled)
                        {
                            m_srcPath[currentEditingGroup]      = m_srcPath.DefaultValue;
                            m_dstPath[currentEditingGroup]      = m_dstPath.DefaultValue;
                            m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue;
                        }
                        else
                        {
                            m_srcPath.Remove(currentEditingGroup);
                            m_dstPath.Remove(currentEditingGroup);
                            m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue;
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    MirrorOption opt       = (MirrorOption)m_mirrorOption[currentEditingGroup];
                    var          newOption = (MirrorOption)EditorGUILayout.EnumPopup("Mirror Option", opt);
                    if (newOption != opt)
                    {
                        using (new RecordUndoScope("Change Mirror Option", node, true)){
                            m_mirrorOption[currentEditingGroup] = (int)newOption;
                            onValueChanged();
                        }
                    }

                    EditorGUILayout.LabelField("Source Directory Path:");

                    string newSrcPath = null;
                    string newDstPath = null;

                    newSrcPath = editor.DrawFolderSelector("", "Select Source Folder",
                                                           m_srcPath[currentEditingGroup],
                                                           Directory.GetParent(Application.dataPath).ToString(),
                                                           (string folderSelected) => {
                        var projectPath = Directory.GetParent(Application.dataPath).ToString();

                        if (projectPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(projectPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(projectPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }
                        return(folderSelected);
                    }
                                                           );
                    if (newSrcPath != m_srcPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Source Folder", node, true)){
                            m_srcPath[currentEditingGroup] = newSrcPath;
                            onValueChanged();
                        }
                    }
                    DrawDirectorySuggestion(GetNormalizedPath(m_srcPath[currentEditingGroup]), currentEditingGroup, onValueChanged);

                    GUILayout.Space(10f);

                    EditorGUILayout.LabelField("Destination Directory Path:");
                    newDstPath = editor.DrawFolderSelector("", "Select Destination Folder",
                                                           m_dstPath[currentEditingGroup],
                                                           Directory.GetParent(Application.dataPath).ToString(),
                                                           (string folderSelected) => {
                        var projectPath = Directory.GetParent(Application.dataPath).ToString();

                        if (projectPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(projectPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(projectPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }
                        return(folderSelected);
                    }
                                                           );

                    if (newDstPath != m_dstPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Destination Folder", node, true)){
                            m_dstPath[currentEditingGroup] = newDstPath;
                            onValueChanged();
                        }
                    }

                    DrawDirectorySuggestion(GetNormalizedPath(m_dstPath[currentEditingGroup]), currentEditingGroup, onValueChanged);
                }
            }
        }
Esempio n. 4
0
 public static Bitmap MirrorBitmap(Bitmap img, MirrorOption side)
 {
     return(MirrorHelper(img, side));
 }