private void MakeButton_Click(object sender, EventArgs e)
        {
            if (!File.Exists(AFilename.Text))
            {
                return;
            }
            if (BFilename.Text == "")
            {
                return;
            }
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            try
            {
                //少し時間がかかるので、しばらくお待ちください表示.
                using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                {
                    DecreaseColor dc = new DecreaseColor();

                    Bitmap src = new Bitmap(AFilename.Text);

                    int  width             = (int)this.ConvertWidth.Value;
                    int  height            = (int)this.ConvertHeight.Value;
                    int  yohaku            = (int)this.ConvertYohaku.Value;
                    int  paletteno         = (int)this.ConvertPaletteNo.Value;
                    bool isReserve1stColor = (this.ConvertReserveColor.SelectedIndex == 1);

                    Bitmap src2;
                    if (this.ConvertSizeMethod.SelectedIndex == 0)
                    {
                        src2 = ImageUtil.BitmapSizeChange(src, 0, 0, width, height);
                    }
                    else
                    {
                        src2 = ImageUtil.BitmapScale(src, width, height);
                    }
                    bool   ignoreTSA = IgnoreTSA.Checked;
                    Bitmap dest      = dc.Convert(src2, paletteno, yohaku, isReserve1stColor, ignoreTSA);

                    U.BitmapSave(dest, BFilename.Text);

                    src.Dispose();
                    src2.Dispose();
                    dest.Dispose();
                }
                //エクスプローラで選択しよう
                U.SelectFileByExplorer(BFilename.Text);
            }
            catch (System.Runtime.InteropServices.ExternalException ee)
            {
                R.ShowStopError(R.ExceptionToString(ee));
            }
            catch (System.ArgumentOutOfRangeException ee)
            {
                R.ShowStopError(R.ExceptionToString(ee));
            }
        }
예제 #2
0
        public void SetReOrderImage1(Bitmap src, int maxPalette, int yohaku, bool isReserve1StPalette)
        {
            //減色する
            DecreaseColor deColor = new DecreaseColor();

            this.ReOrderImage1 = deColor.Convert(src, maxPalette, yohaku, isReserve1StPalette, false);

            this.X_ReOrderImage1.Image = src;//this.ReOrderImage1;
            ChangeScale(this.X_ReOrderImage1);

            X_ReOrderImage1Panel.Show();
        }
예제 #3
0
        void GenSimplePreview()
        {
            //16色に減色.
            DecreaseColor d = new DecreaseColor();

            this.SimplePreviewBitmap16 = d.Convert(this.OrignalImage, 1, 0, true, false);

            ColorPalette pal = this.SimplePreviewBitmap16.Palette;

            pal.Entries[0] = this.TransparentColor;
            this.SimplePreviewBitmap16.Palette = pal;

            this.X_SimplePreview.Image = this.SimplePreviewBitmap16;
        }
예제 #4
0
        Bitmap ConvertBitmap(Bitmap src, int srcx, int srcy)
        {
            U.MakeTransparent(src);

            Bitmap   bitmap = new Bitmap((int)this.BitmapW, (int)this.BitmapH);
            Graphics g      = Graphics.FromImage(bitmap);

            g.DrawImage(src
                        , new Rectangle((int)this.ResizeX.Value, (int)this.ResizeY.Value
                                        , (int)this.ResizeW.Value, (int)this.ResizeH.Value)
                        , new Rectangle(srcx, srcy
                                        , (int)this.PartsX.Value, (int)this.PartsY.Value)
                        , GraphicsUnit.Pixel
                        );

            g.Dispose();

            Bitmap ret;

            if (src.PixelFormat == System.Drawing.Imaging.PixelFormat.Format4bppIndexed)
            {//元々が16色
                string errormessage;
                ret = ImageUtil.ConvertIndexedBitmap(bitmap, src, out errormessage);
            }
            else if (src.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
            {//元々が256色
                string errormessage;
                Bitmap temp = ImageUtil.ConvertIndexedBitmap(bitmap, src, out errormessage);

                DecreaseColor d = new DecreaseColor();
                ret = d.Convert(temp, 1, 0, true, false);

                temp.Dispose();
            }
            else
            {//もともとがフルカラー
                DecreaseColor d = new DecreaseColor();
                ret = d.Convert(bitmap, 1, 0, true, false);
            }

            bitmap.Dispose();

            return(ret);
        }
예제 #5
0
        Bitmap DecreaseColor16(Bitmap bitmap)
        {
            //16色に減色.
            DecreaseColor d        = new DecreaseColor();
            Bitmap        bitmap16 = d.Convert(bitmap, 1, 0, true, false);

            if (this.checkBoxFuchidori.Checked)
            {
                //縁取りすると綺麗に見える
                //黒色を探す
                int blackColorIndex = ImageUtil.FindBlackColorFromPalette(bitmap16, 1, 16);
                //メイン
                bitmap16 = ImageUtil.Fuchidori(bitmap16, (byte)blackColorIndex, new Rectangle(0, 0, 96, 80));
            }

            //パーツをきれいに見せるために再構成する.
            int face_eye_x_id = (int)this.EyeBlockX.Value;
            int face_eye_y_id = (int)this.EyeBlockY.Value;

            int seet_eye_x = (int)(this.EyeX.Value);
            int seet_eye_w = (int)(this.EyeW.Value);
            int seet_eye_y = (int)(this.EyeY.Value);
            int seet_eye_h = (int)(this.EyeH.Value);

            Bitmap tempBitmap;

            if (!this.IsFE6Image)
            {
                tempBitmap = ImageUtil.Copy(bitmap16, face_eye_x_id * 8, face_eye_y_id * 8, 32, 16);
                ImageUtil.BitBlt(tempBitmap, seet_eye_x, seet_eye_y, seet_eye_w, seet_eye_h, bitmap16, seet_eye_x + 96, seet_eye_y + 16 * 3);
                ImageUtil.BitBlt(bitmap16, 96, 16 * 3, 32, 16, tempBitmap, 0, 0);

                tempBitmap = ImageUtil.Copy(bitmap16, face_eye_x_id * 8, face_eye_y_id * 8, 32, 16);
                ImageUtil.BitBlt(tempBitmap, seet_eye_x, seet_eye_y, seet_eye_w, seet_eye_h, bitmap16, seet_eye_x + 96, seet_eye_y + 16 * 4);
                ImageUtil.BitBlt(bitmap16, 96, 16 * 4, 32, 16, tempBitmap, 0, 0);
            }

            int face_mouth_x_id = (int)this.MouthBlockX.Value;
            int face_mouth_y_id = (int)this.MouthBlockY.Value;

            int seet_mouth_x = (int)(this.MouthX.Value);
            int seet_mouth_w = (int)(this.MouthW.Value);
            int seet_mouth_y = (int)(this.MouthY.Value);
            int seet_mouth_h = (int)(this.MouthH.Value);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 0, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 0, 16 * 5, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 1, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 1, 16 * 5, 32, 16, tempBitmap, 0, 0);

            if (!this.IsFE6Image)
            {
                tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
                ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 2, seet_mouth_y + 16 * 5);
                ImageUtil.BitBlt(bitmap16, 32 * 2, 16 * 5, 32, 16, tempBitmap, 0, 0);
            }

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 3, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 3, 16 * 5, 32, 16, tempBitmap, 0, 0);


            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 0, seet_mouth_y + 16 * 6);
            ImageUtil.BitBlt(bitmap16, 32 * 0, 16 * 6, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 1, seet_mouth_y + 16 * 6);
            ImageUtil.BitBlt(bitmap16, 32 * 1, 16 * 6, 32, 16, tempBitmap, 0, 0);

            if (!this.IsFE6Image)
            {
                tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 8, face_mouth_y_id * 8, 32, 16);
                ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 2, seet_mouth_y + 16 * 6);
                ImageUtil.BitBlt(bitmap16, 32 * 2, 16 * 6, 32, 16, tempBitmap, 0, 0);
            }

            return(bitmap16);
        }
        Bitmap DecreaseColor16(Bitmap bitmap, int tileWidth, int tileHeight)
        {
            //16色に減色.
            DecreaseColor d        = new DecreaseColor();
            Bitmap        bitmap16 = d.Convert(bitmap, 1, 0, true, false);

            //縁取りすると綺麗に見える
            //黒色を探す
            int blackColorIndex = ImageUtil.FindBlackColorFromPalette(bitmap16, 1, 16);

            //メイン
            bitmap16 = ImageUtil.Fuchidori(bitmap16, (byte)blackColorIndex, new Rectangle(0, 0, 96, 80));
            //パーツをきれいに見せるために再構成する.
            int face_eye_x_id = (((int)this.EyeX.Value - (int)this.ClipX.Value) / tileWidth);
            int face_eye_y_id = (((int)this.EyeY.Value - (int)this.ClipY.Value) / tileHeight);

            int seet_eye_x = (int)(32 * (this.EyeX.Value - (int)this.ClipX.Value - (face_eye_x_id * tileWidth))) / tileWidth;
            int seet_eye_w = (int)Math.Ceiling((32 * (this.EyeW.Value)) / tileWidth);
            int seet_eye_y = (int)(16 * (this.EyeY.Value - (int)this.ClipY.Value - (face_eye_y_id * tileHeight))) / tileHeight;
            int seet_eye_h = (int)Math.Ceiling((16 * (this.EyeH.Value)) / tileHeight);

            Bitmap tempBitmap;

            tempBitmap = ImageUtil.Copy(bitmap16, face_eye_x_id * 32, face_eye_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_eye_x, seet_eye_y, seet_eye_w, seet_eye_h, bitmap16, seet_eye_x + 96, seet_eye_y + 16 * 3);
            ImageUtil.BitBlt(bitmap16, 96, 16 * 3, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_eye_x_id * 32, face_eye_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_eye_x, seet_eye_y, seet_eye_w, seet_eye_h, bitmap16, seet_eye_x + 96, seet_eye_y + 16 * 4);
            ImageUtil.BitBlt(bitmap16, 96, 16 * 4, 32, 16, tempBitmap, 0, 0);


            int face_mouth_x_id = (((int)this.MouthX.Value - (int)this.ClipX.Value) / tileWidth);
            int face_mouth_y_id = (((int)this.MouthY.Value - (int)this.ClipY.Value) / tileHeight);

            int seet_mouth_x = (int)(32 * (this.MouthX.Value - (int)this.ClipX.Value - (face_mouth_x_id * tileWidth))) / tileWidth;
            int seet_mouth_w = (int)Math.Ceiling((32 * (this.MouthW.Value)) / tileWidth);
            int seet_mouth_y = (int)(16 * (this.MouthY.Value - (int)this.ClipY.Value - (face_mouth_y_id * tileHeight))) / tileHeight;
            int seet_mouth_h = (int)Math.Ceiling((16 * (this.MouthH.Value)) / tileHeight);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 0, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 0, 16 * 5, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 1, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 1, 16 * 5, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 2, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 2, 16 * 5, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 3, seet_mouth_y + 16 * 5);
            ImageUtil.BitBlt(bitmap16, 32 * 3, 16 * 5, 32, 16, tempBitmap, 0, 0);


            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 0, seet_mouth_y + 16 * 6);
            ImageUtil.BitBlt(bitmap16, 32 * 0, 16 * 6, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 1, seet_mouth_y + 16 * 6);
            ImageUtil.BitBlt(bitmap16, 32 * 1, 16 * 6, 32, 16, tempBitmap, 0, 0);

            tempBitmap = ImageUtil.Copy(bitmap16, face_mouth_x_id * 32, face_mouth_y_id * 16, 32, 16);
            ImageUtil.BitBlt(tempBitmap, seet_mouth_x, seet_mouth_y, seet_mouth_w, seet_mouth_h, bitmap16, seet_mouth_x + 32 * 2, seet_mouth_y + 16 * 6);
            ImageUtil.BitBlt(bitmap16, 32 * 2, 16 * 6, 32, 16, tempBitmap, 0, 0);

            return(bitmap16);
        }