Exemplo n.º 1
0
 private void ColorMode(Shapes ss, bool bl)
 {
     foreach (Shape s in ss.FindShapes(null, cdrShapeType.cdrBitmapShape))
     {
         Bitmap       b = s.Bitmap;
         cdrImageType it, tit;
         if (bl)
         {
             it  = cdrImageType.cdrCMYKColorImage;
             tit = cdrImageType.cdrRGBColorImage;
         }
         else
         {
             it  = cdrImageType.cdrRGBColorImage;
             tit = cdrImageType.cdrCMYKColorImage;
         }
         if (b.Mode == it)
         {
             s.ConvertToBitmapEx(tit, false, b.Transparent, b.ResolutionX);
         }
     }
     foreach (Shape s in ss.FindShapes(Query: "@com.PowerClip <> null"))
     {
         s.PowerClip.EnterEditMode();
         ColorMode(application.ActiveLayer.Shapes, bl);
         s.PowerClip.LeaveEditMode();
     }
 }
Exemplo n.º 2
0
 private void Compress(Shapes ss, int px, int cpx)
 {
     foreach (Shape s in ss.FindShapes(null, cdrShapeType.cdrBitmapShape))
     {
         Bitmap b = s.Bitmap;
         if (b.ResolutionX <= px && b.ResolutionY <= px)
         {
             continue;
         }
         s.ConvertToBitmapEx(b.Mode, false, true, cpx, cdrAntiAliasingType.cdrNormalAntiAliasing, true, false, 95);
     }
     foreach (Shape s in ss.FindShapes(Query: "@com.PowerClip <> null"))
     {
         s.PowerClip.EnterEditMode();
         Compress(application.ActiveLayer.Shapes, px, cpx);
         s.PowerClip.LeaveEditMode();
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (application.ActiveDocument.Selection().Shapes.Count == 0)
            {
                MessageBox.Show("请选择一个对象");
                return;
            }
            if (application.ActiveDocument.Selection().Shapes.Count > 1)
            {
                MessageBox.Show("只能选择一个对象");
                return;
            }
            if (application.ActiveShape.Type != cdrShapeType.cdrBitmapShape)
            {
                MessageBox.Show("请选择一个位图");
                return;
            }

            String PSPath = Settings.Default.PSPath;

            if (PSPath == "")
            {
                PSPath = getRegPSPath();
            }
            if (PSPath == "")
            {
                MessageBox.Show("未找到PS主程序photoshop.exe,请手动设置");
                frmSetPSPath f = new frmSetPSPath();
                f.Show(this);
                return;
            }

            StartEvent(true);
            BitmapA = application.ActiveSelectionRange;
            application.ActiveShape.GetMatrix(out d11, out d12, out d21, out d22, out tx, out ty);
            application.ActiveShape.ClearTransformations();

            Bitmap b = application.ActiveShape.Bitmap;

            CPtemp = application.CorelScriptTools().GetTempFolder() + "tisn2015.psd";
            try
            {
                ExportFilter expflt = application.ActiveDocument.ExportBitmap(CPtemp, cdrFilter.cdrPSD, cdrExportRange.cdrSelection, b.Mode, b.SizeWidth, b.SizeHeight, b.ResolutionX, b.ResolutionY, b.Mode == cdrImageType.cdr16ColorsImage ? cdrAntiAliasingType.cdrNoAntiAliasing : cdrAntiAliasingType.cdrNormalAntiAliasing, false, b.Mode == cdrImageType.cdr16ColorsImage ? false : true, true, false, cdrCompressionType.cdrCompressionNone);
                expflt.Finish();
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片不在页面范围,请放入页面范围后重试!") ;
            }
            application.ActiveShape.SetMatrix(d11, d12, d21, d22, tx, ty);

            dtB = File.GetLastWriteTime(CPtemp);
            Process.Start(PSPath, CPtemp);
            if (MessageBox.Show("编辑完成单击确认,放弃编辑单击取消", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
            {
                dtA = File.GetLastWriteTime(CPtemp);
                if (dtA > dtB)
                {
                    EditEnd();
                }
            }
            EndEvent();
            SetForegroundWindow(new IntPtr(application.AppWindow.Handle));
            //application.AppWindow.WindowState = cdrWindowState.cdrWindowRestore;
            //timer1.Start();
        }