private bool IsNotSup(cdrFilter flt) { if (flt != cdrFilter.cdrCDR) { return(true); } return(false); }
private bool ExportImage(Document d, XmlNode preset, string filePath, cdrFilter filter, cdrExportRange range, StructExportOptions opt) { try { Corel.Interop.VGCore.ICorelExportFilter exp; exp = d.ExportEx(filePath, filter, range, opt); object[] param = new Object[1]; if (preset.Attributes["format"].Value == "Jpeg") { param[0] = ValToBool(preset.Attributes["progressive"].Value); exp.GetType().InvokeMember("Progressive", BindingFlags.SetProperty, null, exp, param); param[0] = ValToBool(preset.Attributes["optimize"].Value); exp.GetType().InvokeMember("Optimized", BindingFlags.SetProperty, null, exp, param); if (preset.Attributes["subformat"].Value == "Standard (4:2:2)") { param[0] = 0; } else { param[0] = 1; } exp.GetType().InvokeMember("SubFormat", BindingFlags.SetProperty, null, exp, param); param[0] = 100 - Convert.ToInt32(preset.Attributes["quality"].Value); exp.GetType().InvokeMember("Compression", BindingFlags.SetProperty, null, exp, param); param[0] = Convert.ToInt32(preset.Attributes["blur"].Value); exp.GetType().InvokeMember("Smoothing", BindingFlags.SetProperty, null, exp, param); } else { param[0] = ValToBool(preset.Attributes["interlaced"].Value); exp.GetType().InvokeMember("Interlaced", BindingFlags.SetProperty, null, exp, param); } exp.Finish(); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
//exports image private void ExportImage(VGCore.ShapeRange kit, VGCore.Shape background, cdrFilter imageType, int width, int height, string variant = null, string number = null, string name = null) { ShapeRange exportRange = kit; exportRange.Add(background); exportRange.CreateSelection(); String fileName = this.appDraw.ActiveDocument.FileName; String filePath = this.appDraw.ActiveDocument.FilePath; fileName = fileName.Remove(fileName.Length - 4, 4); String suffix = ""; ExportFilter expFil; if (variant == null) { if (background.Name != "FMR_W.cdr") { suffix = " -" + background.Name.ElementAt(4); } if (imageType == cdrFilter.cdrPNG) { suffix += ".png"; } expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300); } else { if (imageType == cdrFilter.cdrJPEG) { suffix += ".jpg"; } //fileName = variant + fileName.Substring(6); expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300, cdrAntiAliasingType.cdrNormalAntiAliasing, false, false, true, false, cdrCompressionType.cdrCompressionJPEG); } expFil.Finish(); }
//runs ArrangeBackground, ExportImage and deletes background to keep the file sizes low. private void ArrangeExportAndCleanup(VGCore.ShapeRange kit, VGCore.Shape background, cdrFilter filter, int Width, int Height, string variant = null, string number = null, string name = null) { ArrangeBackground(kit, background, variant, number, name); ExportImage(kit, background, filter, Width, Height, variant, number, name); background.Delete(); }
private void ExportJPG(Page page) { if (page.Shapes.Count == 0) { addMessage("页面无对象"); return; } page.Activate(); String namen; if (rbDocument.Checked) { namen = application.ActiveDocument.Name; } else { namen = outFileName; } application.ActiveDocument.Unit = cdrUnit.cdrPixel; cdrFilter filter = getFilter(); String ext = getExt(); String DestDir, FileName; ExportFilter ef; StructExportOptions seo = application.CreateStructExportOptions(); seo.AntiAliasingType = cbSmooth.Checked ? cdrAntiAliasingType.cdrSupersampling : cdrAntiAliasingType.cdrNoAntiAliasing; seo.ImageType = (cdrImageType)cbCM.SelectedIndex; seo.Compression = (cdrCompressionType)cbYSSF.SelectedIndex; seo.UseColorProfile = cbUseColorProfile.Checked; //特别注意,透明度在jpg等无透明的格式的时候不能为True,不然光滑处理将会失效 seo.Transparent = checkBox_trans.Checked; seo.AlwaysOverprintBlack = checkBox_OverPrintBlack.Checked; seo.MaintainLayers = checkBox_MaintainLayers.Checked; int s = 72; if (cboFbl.Text != "") { int.TryParse(cboFbl.Text, out s); } seo.ResolutionX = s; seo.ResolutionY = s; double sc = 1; if (comboBox_SC.Text != "") { double.TryParse(comboBox_SC.Text, out sc); } if (sc == 0) { addMessage("放大部数不能为0,取消。。"); return; } if (sc != 1) { double[] dt = getSize(page); seo.SizeX = (int)(dt[0] * sc * (s / 300.0)); seo.SizeY = (int)(dt[1] * sc * (s / 300.0)); } DestDir = tbPath.Text; if (!DestDir.EndsWith("\\")) { DestDir += "\\"; } if (rbSelection.Checked) { FileName = DestDir + namen + getPageName(page) + getIndex() + getUnit(0, 0) + ext; if (CheckFilExists(FileName)) { addMessage("文件已存在,取消"); return; } page.Activate(); ef = application.ActiveDocument.ExportEx(FileName, filter, cdrExportRange.cdrSelection, seo); ef.Finish(); return; } else if (rbSelRge.Checked) { Rect rct = application.CreateRect(); ShapeRange sr = application.ActiveSelectionRange; rct.x = sr.LeftX; rct.y = sr.BottomY; rct.Width = sr.SizeWidth; rct.Height = sr.SizeHeight; seo.set_ExportArea(ref rct); FileName = DestDir + namen + getPageName(page) + getIndex() + getUnit(0, 0) + ext; if (CheckFilExists(FileName)) { addMessage("文件已存在,取消"); return; } page.Activate(); ef = application.ActiveDocument.ExportEx(FileName, filter, cdrExportRange.cdrCurrentPage, seo); ef.Finish(); return; } else if (cbPageScope.Checked) { Rect rct = application.CreateRect(); if (cbPageHalf.Checked) { bool hz = cbHalfOp.SelectedIndex == 0 ? true : false; rct.x = page.LeftX; rct.y = page.BottomY; if (hz) { rct.Width = page.SizeWidth; rct.Height = page.SizeHeight / 2; rct.y = page.SizeHeight / 2; } else { rct.Width = page.SizeWidth / 2; rct.Height = page.SizeHeight; } seo.set_ExportArea(rct); FileName = DestDir + namen + getPageName(page) + "-1前" + getIndex() + getUnit(0, 0) + ext; if (CheckFilExists(FileName)) { addMessage("文件已存在,取消"); return; } ef = application.ActiveDocument.ExportEx(FileName, filter, cdrExportRange.cdrCurrentPage, seo); ef.Finish(); if (hz) { rct.y = page.BottomY; } else { rct.x = page.SizeWidth / 2; } seo.set_ExportArea(rct); FileName = DestDir + namen + getPageName(page) + "-2后" + getIndex() + getUnit(0, 0) + ext; if (CheckFilExists(FileName)) { addMessage("文件已存在,取消"); return; } ef = application.ActiveDocument.ExportEx(FileName, filter, cdrExportRange.cdrCurrentPage, seo); ef.Finish(); return; } else { rct = application.CreateRect(page.LeftX, page.BottomY, page.SizeWidth, page.SizeHeight); //rct.x = page.LeftX; //rct.y = page.BottomY; //rct.Width = page.SizeWidth; //rct.Height = page.SizeHeight; seo.set_ExportArea(rct); //MessageBox.Show("x:" + rct.x + ",y:" + rct.y + ",width:" + rct.Width + ",height" + rct.Height); } } FileName = DestDir + namen + getPageName(page) + getIndex() + getUnit(0, 0) + ext; if (CheckFilExists(FileName)) { addMessage("文件已存在,取消"); return; } ef = application.ActiveDocument.ExportEx(FileName, filter, cdrExportRange.cdrCurrentPage, seo); ef.Finish(); }
private bool ExportImage(Document d, XmlNode preset, string filePath, cdrFilter filter, cdrExportRange range, StructExportOptions opt) { try { Corel.Interop.VGCore.ICorelExportFilter exp; exp = d.ExportEx(filePath, filter, range, opt); object[] param = new Object[1]; if (preset.Attributes["format"].Value == "Jpeg") { param[0] = ValToBool(preset.Attributes["progressive"].Value); exp.GetType().InvokeMember("Progressive", BindingFlags.SetProperty, null, exp, param); param[0] = ValToBool(preset.Attributes["optimize"].Value); exp.GetType().InvokeMember("Optimized", BindingFlags.SetProperty, null, exp, param); if (preset.Attributes["subformat"].Value == "Standard (4:2:2)") param[0] = 0; else param[0] = 1; exp.GetType().InvokeMember("SubFormat", BindingFlags.SetProperty, null, exp, param); param[0] = 100 - Convert.ToInt32(preset.Attributes["quality"].Value); exp.GetType().InvokeMember("Compression", BindingFlags.SetProperty, null, exp, param); param[0] = Convert.ToInt32(preset.Attributes["blur"].Value); exp.GetType().InvokeMember("Smoothing", BindingFlags.SetProperty, null, exp, param); } else { param[0] = ValToBool(preset.Attributes["interlaced"].Value); exp.GetType().InvokeMember("Interlaced", BindingFlags.SetProperty, null, exp, param); } exp.Finish(); return true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; } }