示例#1
0
        private bool addpic(string lei, int index)
        {
            Bitmap         bitmap         = new Bitmap(1, 1);
            int            num            = 1;
            int            num2           = 0;
            int            num3           = 0;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = !(lei == "tihuan");
            openFileDialog.Filter      = "所有文件|*.*".Language();
            openFileDialog.Getpath("pic");
            bool result;

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                result = false;
            }
            else
            {
                openFileDialog.Putpath("pic");
                guiimagetype guiimagetype = default(guiimagetype);
                string[]     fileNames    = openFileDialog.FileNames;
                for (int i = 0; i < fileNames.Length; i++)
                {
                    string file = fileNames[i];
                    this.label1.Text = "正在转换图片".Language() + num.ToString();
                    num++;
                    Application.DoEvents();
                    bitmap = new Bitmap(1, 1);
                    if (this.openpic(ref bitmap, file))
                    {
                        num3++;
                        guiimagetype.imagebytes = new byte[bitmap.Width * bitmap.Height * 2];
                        int num4 = 0;
                        for (int j = 0; j < bitmap.Height; j++)
                        {
                            for (int k = 0; k < bitmap.Width; k++)
                            {
                                if (bitmap.GetPixel(k, j).A == 0)
                                {
                                    guiimagetype.imagebytes[num4]     = (byte)(datasize.Color_touming % 256);
                                    guiimagetype.imagebytes[num4 + 1] = 0;
                                }
                                else
                                {
                                    ushort num5 = bitmap.GetPixel(k, j).Get16Color();
                                    guiimagetype.imagebytes[num4]     = (byte)(num5 % 256);
                                    guiimagetype.imagebytes[num4 + 1] = (byte)(num5 / 256);
                                    if ((ushort)guiimagetype.imagebytes[num4] == datasize.Color_touming && guiimagetype.imagebytes[num4 + 1] == 0)
                                    {
                                        guiimagetype.imagebytes[num4] = (byte)datasize.Color_toumingtihuan;
                                    }
                                }
                                num4 += 2;
                            }
                        }
                        guiimagetype.picturexinxi.qumo = Convert.ToByte(this.Myapp.guidire + 10);
                        if (guiimagetype.picturexinxi.qumo != 10)
                        {
                            Kuozhan.getxuanzhuanimage(guiimagetype.imagebytes, ref guiimagetype.imagebytes, bitmap.Width, bitmap.Height, 0, (int)this.Myapp.guidire);
                        }
                        guiimagetype.picturexinxi.H           = (ushort)bitmap.Height;
                        guiimagetype.picturexinxi.imgbytesize = (uint)guiimagetype.imagebytes.Length;
                        guiimagetype.picturexinxi.W           = (ushort)bitmap.Width;
                        guiimagetype.imagebitbmp = guiimagetype.imagebytes.GetBitmap(guiimagetype.picturexinxi, datasize.Opentouming);
                        guiimagetype.imgxulie    = guiimagetype.imagebitbmp.ClassToBytes();
                        if (lei == "add")
                        {
                            this.Myapp.images.Add(guiimagetype);
                        }
                        else if (lei == "insert")
                        {
                            if (index >= this.Myapp.images.Count)
                            {
                                result = false;
                                return(result);
                            }
                            this.Myapp.images.Insert(index, guiimagetype);
                        }
                        else if (lei == "tihuan")
                        {
                            this.Myapp.images[index] = guiimagetype;
                        }
                    }
                    else
                    {
                        num2++;
                    }
                    if (bitmap != null)
                    {
                        bitmap.Dispose();
                    }
                }
                if (num3 > 0 && lei == "insert")
                {
                    byte[] array = ((ushort)index).structToBytes();
                    foreach (mpage current in this.Myapp.pages)
                    {
                        foreach (mobj current2 in current.objs)
                        {
                            foreach (matt current3 in current2.atts)
                            {
                                if (current3.att.attlei == attshulei.Picid.typevalue)
                                {
                                    ushort num6 = (ushort)current3.zhi.BytesTostruct(0.GetType());
                                    if (num6 != 65535 && (int)num6 >= index)
                                    {
                                        current3.zhi = ((ushort)((int)num6 + num3)).structToBytes();
                                    }
                                }
                            }
                        }
                    }
                    foreach (mpage current in this.Myapp.pages)
                    {
                        foreach (objsetcom_P current4 in current.objsetcomps)
                        {
                            foreach (objsetcom current5 in current4.objset)
                            {
                                if (current5.backobj != null)
                                {
                                    foreach (matt current3 in current5.backobj.atts)
                                    {
                                        if (current3.att.attlei == attshulei.Picid.typevalue)
                                        {
                                            ushort num6 = (ushort)current3.zhi.BytesTostruct(0.GetType());
                                            if (num6 != 65535 && (int)num6 >= index)
                                            {
                                                current3.zhi = ((ushort)((int)num6 + num3)).structToBytes();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    foreach (mobj current2 in this.Myapp.copymobjs)
                    {
                        foreach (matt current3 in current2.atts)
                        {
                            if (current3.att.attlei == attshulei.Picid.typevalue)
                            {
                                ushort num6 = (ushort)current3.zhi.BytesTostruct(0.GetType());
                                if (num6 != 65535 && (int)num6 >= index)
                                {
                                    current3.zhi = ((ushort)((int)num6 + num3)).structToBytes();
                                }
                            }
                        }
                    }
                }
                if (num2 == 0)
                {
                    MessageOpen.Show(string.Concat(new string[]
                    {
                        "成功导入".Language(),
                        " ",
                        num3.ToString(),
                        " ",
                        "张".Language()
                    }));
                }
                else
                {
                    MessageOpen.Show(string.Concat(new string[]
                    {
                        "成功导入".Language(),
                        " ",
                        num3.ToString(),
                        " ",
                        "张,失败".Language(),
                        " ",
                        num2.ToString(),
                        " ",
                        "张".Language()
                    }));
                }
                result = true;
            }
            return(result);
        }
示例#2
0
        private void qumozhuan()
        {
            guiimagetype value     = default(guiimagetype);
            zimoxinxi    zimoxinxi = default(zimoxinxi);
            byte         b         = Convert.ToByte(this.Myapp.guidire + 10);

            for (int i = 0; i < this.Myapp.images.Count; i++)
            {
                this.label3.Visible = true;
                if (this.Myapp.images[i].picturexinxi.qumo != b)
                {
                    this.label3.Text = "正在转换资源文件:".Language() + i.ToString() + "/" + this.Myapp.images.Count.ToString();
                    Application.DoEvents();
                    int num = (int)this.Myapp.images[i].picturexinxi.qumo;
                    value = this.Myapp.images[i];
                    if (num == 1)
                    {
                        Kuozhan.zhuanimg(this.Myapp.images[i].imagebytes, ref value.imagebytes, (int)this.Myapp.images[i].picturexinxi.W, (int)this.Myapp.images[i].picturexinxi.H);
                        num = 10;
                    }
                    else if (num == 0)
                    {
                        num = 10;
                    }
                    if (num != (int)b)
                    {
                        Kuozhan.getxuanzhuanimage(this.Myapp.images[i].imagebytes, ref value.imagebytes, (int)this.Myapp.images[i].picturexinxi.W, (int)this.Myapp.images[i].picturexinxi.H, num - 10, (int)(b - 10));
                    }
                    value.picturexinxi.qumo = b;
                    this.Myapp.images[i]    = value;
                }
            }
            for (int i = 0; i < this.Myapp.zimos.Count; i++)
            {
                zimoxinxi = this.Myapp.zimos[i];
                if ((int)zimoxinxi.encode < datasize.encodes_App.Length)
                {
                    if (zimoxinxi.ver == 0 || zimoxinxi.ver == 1)
                    {
                        if (zimoxinxi.encode == 0)
                        {
                            if (zimoxinxi.state == 0 && datasize.Language == 1)
                            {
                                zimoxinxi.encode = (byte)((zimoxinxi.qyt < 100u) ? 1 : 3);
                            }
                            else
                            {
                                zimoxinxi.encode = 2;
                            }
                        }
                        zimoxinxi.codelT0    = 255;
                        zimoxinxi.codelV0    = 0;
                        zimoxinxi.codeh_star = datasize.encodes_App[(int)zimoxinxi.encode].codeh_star;
                        zimoxinxi.codeh_end  = datasize.encodes_App[(int)zimoxinxi.encode].codeh_end;
                        zimoxinxi.codel_star = datasize.encodes_App[(int)zimoxinxi.encode].codel_star;
                        zimoxinxi.codel_end  = datasize.encodes_App[(int)zimoxinxi.encode].codel_end;
                    }
                }
                if (zimoxinxi.ver != 0)
                {
                    zimoxinxi.ver = datasize.zikuver;
                }
                this.label3.Visible = true;
                if (this.Myapp.zimos[i].qumo != b)
                {
                    this.label3.Text = "正在转换字库文件:".Language() + i.ToString() + "/" + this.Myapp.zimos.Count.ToString();
                    Application.DoEvents();
                    int num = (int)this.Myapp.zimos[i].qumo;
                    if (zimoxinxi.ver == 0)
                    {
                        if (zimoxinxi.state == 2)
                        {
                            byte[] array = new byte[this.Myapp.zimodatas[i].Length];
                            int    j;
                            for (j = 0; j <= (int)zimoxinxi.datastar; j++)
                            {
                                array[j] = this.Myapp.zimodatas[i][j];
                            }
                            int num2 = (int)(zimoxinxi.datastar + 1);
                            int num3 = num2;
                            int num4 = (int)(zimoxinxi.w * zimoxinxi.h / 8 + 2);
                            j = 0;
                            while ((long)j < (long)((ulong)zimoxinxi.qyt))
                            {
                                array[num2]     = this.Myapp.zimodatas[i][num3];
                                array[num2 + 1] = this.Myapp.zimodatas[i][num3 + 1];
                                num2           += 2;
                                num3           += num4;
                                j++;
                            }
                            num3 = (int)(zimoxinxi.datastar + 1);
                            j    = 0;
                            while ((long)j < (long)((ulong)zimoxinxi.qyt))
                            {
                                num3 += 2;
                                for (int k = 0; k < num4 - 2; k++)
                                {
                                    array[num2] = this.Myapp.zimodatas[i][num3];
                                    num2++;
                                    num3++;
                                }
                                j++;
                            }
                            this.Myapp.zimodatas[i] = array;
                            zimoxinxi.ascstar       = (byte)(this.Myapp.zimos[i].datastar + 1);
                            zimoxinxi.datastar      = (ushort)((uint)zimoxinxi.ascstar + zimoxinxi.qyt * 2u);
                        }
                        else
                        {
                            zimoxinxi.ascstar  = (byte)(this.Myapp.zimos[i].datastar + 1);
                            zimoxinxi.datastar = (ushort)zimoxinxi.ascstar;
                        }
                        this.Myapp.zimodatas[i] = Kuozhan.getxuanzhuanziku(zimoxinxi, this.Myapp.zimodatas[i], 4, 0);
                        num           = 10;
                        zimoxinxi.ver = datasize.zikuver;
                    }
                    if (num != (int)b)
                    {
                        this.Myapp.zimodatas[i] = Kuozhan.getxuanzhuanziku(zimoxinxi, this.Myapp.zimodatas[i], num - 10, (int)(b - 10));
                    }
                    zimoxinxi.qumo      = b;
                    this.Myapp.zimos[i] = zimoxinxi;
                }
            }
        }