예제 #1
0
        /// <summary>
        /// OpenGLの初期設定
        /// </summary>
        private void SetupOpenGL()
        {
            //以下、初期化処理
            this.mCanvasWidth  = this.Width;
            this.mCanvasHeight = this.Height;

            //以下、背景色初期化処理
            Gl.glClearColor(this.mBackColor.R / 255.0f, this.mBackColor.G / 255.0f, this.mBackColor.B / 255.0f, 1.0f);

            //以下、深度テストを有効化
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthFunc(Gl.GL_LEQUAL);

            //以下、半透明設定
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);

            //以下、スムースシェイディング設定
            Gl.glShadeModel(Gl.GL_SMOOTH);

            //以下、テクスチャー表示有効化設定
            Gl.glEnable(Gl.GL_TEXTURE_2D);

            //以下、日時初期化処理
            this.mTimeOld = DateTime.Now;

            //以下、フォント作成処理
            this.mImageFont = new ClsDatImage();
            this.mImageFont.SetImage(Properties.Resources.font);
        }
예제 #2
0
        /// <summary>
        /// 同じイメージが存在するかチェックする
        /// </summary>
        /// <param name="clImage">イメージ</param>
        /// <returns>存在フラグ</returns>
        public static bool IsExistImageFromImage(Image clImage)
        {
            if (clImage == null)
            {
                return(false);
            }

            string clHash = ClsTool.GetMD5FromImage(clImage);

            foreach (int inKey in ClsSystem.mDicImage.Keys)
            {
                ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                if (clDatImage.mImgOrigin == null)
                {
                    continue;
                }

                string clHashTmp = ClsTool.GetMD5FromImage(clDatImage.mImgOrigin);
                if (!clHashTmp.Equals(clHash))
                {
                    continue;
                }

                return(true);
            }

            return(false);
        }
예제 #3
0
 /// <summary>
 /// イメージ全削除処理
 /// </summary>
 public static void RemoveAllImage()
 {
     foreach (int inKey in ClsSystem.mDicImage.Keys)
     {
         ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
         clDatImage.Remove();
     }
     ClsSystem.mDicImage.Clear();
 }
예제 #4
0
        /// <summary>
        /// イメージを作成する
        /// イメージファイルパスからファイルを読み込んでSystem.mListImageに追加して、インデックスを返します
        /// ただし、すでにSystem.mListImageに存在していた場合は、リストに追加せずに、そのインデックスを返します
        /// </summary>
        /// <param name="clFilePath">イメージファイルパス</param>
        /// <returns>イメージキー</returns>
        public static int CreateImageFromFile(string clFilePath)
        {
            Image clImage = Bitmap.FromFile(clFilePath);

            int         inKey      = ClsSystem.CreateImageFromImage(clImage);
            ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];

            clDatImage.mPath = clFilePath;

            return(inKey);
        }
예제 #5
0
        /// <summary>
        /// イメージ取得処理
        /// </summary>
        /// <param name="inKey">イメージキー</param>
        /// <returns>イメージ管理クラス</returns>
        public static ClsDatImage GetImage(int inKey)
        {
            bool isExist = ClsSystem.mDicImage.ContainsKey(inKey);

            if (!isExist)
            {
                return(null);
            }

            ClsDatImage clImage = ClsSystem.mDicImage[inKey];

            return(clImage);
        }
예제 #6
0
        /// <summary>
        /// 選択中のインデックスのリストを取得する
        /// </summary>
        /// <returns>選択中のインデックスのリスト</returns>
        public static List <int> GetImageSelectIndex()
        {
            List <int> clListIndex = new List <int>();

            foreach (int inKey in ClsSystem.mDicImage.Keys)
            {
                ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                if (!clDatImage.mSelect)
                {
                    continue;
                }

                clListIndex.Add(inKey);
            }

            return(clListIndex);
        }
예제 #7
0
        /// <summary>
        /// イメージを作成する
        /// イメージをSystem.mListImageに追加して、インデックスを返します
        /// ただし、すでにSystem.mListImageに存在していた場合は、リストに追加せずに、そのインデックスを返します
        /// </summary>
        /// <param name="clImage">イメージ</param>
        /// <returns>イメージキー</returns>
        public static int CreateImageFromImage(Image clImage)
        {
            int inKey = ClsSystem.GetImageIndexFromImage(clImage);

            if (inKey >= 0)
            {
                return(inKey);
            }

            //以下、イメージを新規作成して、そのインデックスを返す処理
            ClsDatImage clDatImage = new ClsDatImage();

            clDatImage.SetImage(clImage);
            clDatImage.mID = ClsSystem.GetNewID();
            ClsSystem.mDicImage.Add(clDatImage.mID, clDatImage);

            return(clDatImage.mID);
        }
예제 #8
0
        /// <summary>
        /// 保存処理
        /// </summary>
        /// <param name="clFilePath">ファイルパス</param>
        public static void Save(string clFilePath)
        {
            ClsSystem.mFileBuffer = new StringBuilder();

            //以下、プロジェクトファイル保存処理
            string clLine = "?xml version=\"1.0\" encoding=\"utf-8\"?";

            ClsTool.AppendElementStart("", clLine);

            clLine = "HanimProjectData xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
            ClsTool.AppendElementStart("", clLine);

            string clHeader     = ClsSystem.FILE_TAG;
            string clHeaderName = "hap";

            ClsTool.AppendElement(clHeader, "Header", clHeaderName);

            int inVersion = 1;

            ClsTool.AppendElement(clHeader, "Ver", inVersion);

            //以下、イメージリスト保存処理
            foreach (int inKey in ClsSystem.mDicImage.Keys)
            {
                ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                clDatImage.Save(clHeader);
            }

            //以下、モーションリスト保存処理
            foreach (int inKey in ClsSystem.mDicMotion.Keys)
            {
                ClsDatMotion clDatMotion = ClsSystem.mDicMotion[inKey];
                clDatMotion.Save(clHeader);
            }

            ClsTool.AppendElementEnd("", "HanimProjectData");

            //以下、プロジェクトファイル保存処理
            string clBuffer = ClsSystem.mFileBuffer.ToString();

            File.WriteAllText(clFilePath, clBuffer, Encoding.UTF8);
        }
예제 #9
0
        /// <summary>
        /// イメージ削除処理
        /// </summary>
        /// <param name="inKey">イメージキー</param>
        public static void RemoveImage(int inKey)
        {
            if (inKey <= 0)
            {
                return;
            }

            bool isExist = ClsSystem.mDicImage.ContainsKey(inKey);

            if (!isExist)
            {
                return;
            }

            ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];

            clDatImage.Remove();

            ClsSystem.mDicImage.Remove(inKey);
        }
예제 #10
0
        /// <summary>
        /// イメージ作成処理
        /// </summary>
        /// <param name="clImageSrc">オリジナル画像</param>
        /// <param name="clImageSmall">縮小画像</param>
        private void CreateImage(Image clImageSrc, ref Image clImageSmall)
        {
            Rectangle stRectSrc = new Rectangle(0, 0, clImageSrc.Width, clImageSrc.Height);

            //以下、縮小画像作成処理
            clImageSmall = ClsDatImage.CreateSmallImage(clImageSrc, 32, 32);

            //以下、OpenGL用の画像を作成する処理
            Bitmap clBitmap = (Bitmap)clImageSrc.Clone();

            clBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
            Rectangle  stRect       = new Rectangle(0, 0, clBitmap.Width, clBitmap.Height);
            BitmapData clBitmapData = clBitmap.LockBits(stRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

            Gl.glGenTextures(1, this.mListTex);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.mListTex[0]);
            Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, clBitmap.Width, clBitmap.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, clBitmapData.Scan0);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST);
        }
예제 #11
0
        private void button_Cut_Click(object sender, EventArgs e)
        {
            List <int> clListIndex = ClsSystem.GetImageSelectIndex();

            if (clListIndex.Count <= 0)
            {
                return;
            }

            //以下、元画像取得処理
            int         inSelectKey   = clListIndex[0];
            ClsDatImage clDatImageSrc = ClsSystem.mDicImage[inSelectKey];

            //以下、イメージカットウィンドウ表示処理
            FormImageCut clFormImageCut = new FormImageCut(this.mFormMain, clDatImageSrc.mImgOrigin, clDatImageSrc.mPath);
            DialogResult enResult       = clFormImageCut.ShowDialog();

            if (enResult == DialogResult.OK)
            {
                int inCnt, inMax = clFormImageCut.mListCutImage.Count;
                for (inCnt = 0; inCnt < inMax; inCnt++)
                {
                    //以下、画像登録処理
                    ClsDatCutImage clDatCutImage = clFormImageCut.mListCutImage[inCnt];
                    int            inKey         = ClsSystem.CreateImageFromImage(clDatCutImage.mImage);

                    //以下、カット画像管理クラスにカット情報を登録する処理
                    ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                    clDatImage.mPath = clDatImageSrc.mPath;
                    clDatImage.mRect = new ClsDatRect(clDatCutImage.mX, clDatCutImage.mY, clDatCutImage.mW, clDatCutImage.mH);
                }
            }
            clFormImageCut.Close();
            clFormImageCut.Dispose();
            clFormImageCut = null;

            //以下、リフレッシュ処理
            this.Refresh();
        }
예제 #12
0
        private void button_Divid_Click(object sender, EventArgs e)
        {
            //等間隔分割
            int dx = (int)numericUpDown_DivX.Value;
            int dy = (int)numericUpDown_DivY.Value;

            for (int cy = 0; cy < (mImage.Height / dy); cy++)
            {
                for (int cx = 0; cx < (mImage.Width / dx); cx++)
                {
                    ClsDatImage c = new ClsDatImage();
                    c.mRect = new ClsDatRect(cx * dx, cy * dy, dx, dy);
//                    ImageManager.AddImageChipFromImage(mImage, c);
                    //※ここでイメージをカットする?
                }
            }
            mPosStart = new Point(0, 0);
            mPosEnd   = new Point(dx, dy);//仮

            panel_CellList.Width  = splitContainerBase.ClientSize.Width;
            panel_CellList.Height = (this.mListCutImage.Count / (panel_CellList.Width / FormImageCut.WIDTH_THUMS) + 1) * FormImageCut.WIDTH_THUMS;
            //splitContainerBase.Refresh();
        }
예제 #13
0
        private void button_Delete_Click(object sender, EventArgs e)
        {
            List <int> clListRemove = new List <int>();

            foreach (int inKey in ClsSystem.mDicImage.Keys)
            {
                ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                if (!clDatImage.mSelect)
                {
                    continue;
                }

                clListRemove.Add(inKey);
            }

            int inCnt, inMax = clListRemove.Count;

            for (inCnt = 0; inCnt < inMax; inCnt++)
            {
                int  inKey   = clListRemove[inCnt];
                bool isExist = ClsSystem.mDicImage.ContainsKey(inKey);
                if (!isExist)
                {
                    continue;
                }

                ClsDatImage clDatImage = ClsSystem.mDicImage[inKey];
                if (clDatImage == null)
                {
                    continue;
                }

                ClsSystem.RemoveImage(inKey);
            }

            panel_listBase.Refresh();
        }
예제 #14
0
        /// <summary>
        /// 読み込み処理
        /// </summary>
        /// <param name="clListView">モーションリストビュー</param>
        /// <param name="clFilePath">ファイルパス</param>
        public static void Load(ListView clListView, string clFilePath)
        {
            ClsSystem.mMotionSelectKey = -1;

            XmlDocument clXmlDoc = new XmlDocument();

            try
            {
                //以下、xmlファイル読み込み処理
                clXmlDoc.Load(clFilePath);

                //以下、プロジェクトファイル読み込み処理
                IEnumerator iEnum = clXmlDoc.DocumentElement.GetEnumerator();
                while (iEnum.MoveNext())
                {
                    XmlElement clXmlElem = iEnum.Current as XmlElement;

                    if ("Header".Equals(clXmlElem.Name))
                    {
                        if (!"hap".Equals(clXmlElem.InnerText))
                        {
                            throw new Exception("this is not hanim project file.");
                        }

                        ClsSystem.mHeader = clXmlElem.InnerText;
                        continue;
                    }

                    if ("Ver".Equals(clXmlElem.Name))
                    {
                        Match clMatch = Regex.Match(clXmlElem.InnerText, "^\\d+$");
                        if (!clMatch.Success)
                        {
                            throw new Exception("this is not allowed version.");
                        }

                        ClsSystem.mVer = Convert.ToInt32(clXmlElem.InnerText);
                        continue;
                    }

                    if ("Image".Equals(clXmlElem.Name))
                    {
                        ClsDatImage clDatImage = new ClsDatImage();
                        clDatImage.Load(clXmlElem);

                        ClsSystem.mDicImage.Add(clDatImage.mID, clDatImage);
                        continue;
                    }

                    if ("Motion".Equals(clXmlElem.Name))
                    {
                        ClsDatMotion clDatMotion = new ClsDatMotion(0, "");
                        clDatMotion.Load(clXmlElem);

                        ListViewItem clListViewItem = new ListViewItem(clDatMotion.mName, 2);
                        clListView.Items.Add(clListViewItem);
                        clListViewItem.Tag = ClsSystem.mDicMotion.Count;

                        clDatMotion.mItemHashCode = clListViewItem.GetHashCode();
                        clDatMotion.Restore();       //モーションの親子関連付け再構築処理
                        clDatMotion.RefreshLineNo(); //行番号などを設定する処理
                        ClsSystem.mDicMotion.Add(clDatMotion.mID, clDatMotion);
                        continue;
                    }

                    throw new Exception("this is abnormality format.");
                }

                //以下、デフォルトで選択しているモーションを設定する処理
                if (clListView.Items.Count >= 1)
                {
                    ClsSystem.mMotionSelectKey = clListView.Items[0].GetHashCode();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }