Ejemplo n.º 1
0
        private void SaveAsImage_Shown(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();

            axPXV_Control1.CreateNewBlankDoc(500, 500, 1);

            var page = axPXV_Control1.Doc.CoreDoc.Pages[0];
            var CC   = axPXV_Control1.Doc.CoreDoc.CreateContentCreator();
            //page.Document.AddImageFromFile(openFileDialog1.FileName);
            //axPXV_Control1.Doc.CoreDoc.WriteToFile(openFileDialog1.FileName);
            IXC_ImageFileFormatIDs img = IXC_ImageFileFormatIDs.FMT_PBM_ID;

            page.Document.WriteToFile(openFileDialog1.FileName);
            IXC_PageFormat nFormat = IXC_PageFormat.PageFormat_8Indexed;
            //ConvertFormatToIndx(page, nFormat);
            IXC_Channel sd = IXC_Channel.Channel_R;
            IIXC_Page   d;

            axPXV_Control1.CreateNewBlankDoc(600, 600, 1);
            PXC_BoxType bx  = new PXC_BoxType();
            PXC_Matrix  mtr = page.GetMatrix(bx);

            page.GetMatrix(bx);
            tagRECT   tgRct = new tagRECT();
            IIXC_Inst inst  = (IIXC_Inst)axPXV_Control1.Inst.GetExtension("IXC");
        }
Ejemplo n.º 2
0
        static public int ConvertToPDF(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.CreateNewDoc(Parent);
            }

            IIXC_Inst  ixcInst = Parent.m_pxcInst.GetExtension("IXC");
            IAUX_Inst  auxInst = Parent.m_pxcInst.GetExtension("AUX");
            IPXC_Pages pages   = Parent.m_CurDoc.Pages;
            IPXC_Page  Page    = pages[0];
            double     nHeight = 0.0;
            double     nWidth  = 0.0;

            Page.GetDimension(out nWidth, out nHeight);
            IIXC_Image img = ixcInst.CreateEmptyImage();

            img.Load(System.Environment.CurrentDirectory + "\\Images\\Editor_welcome.png");
            IIXC_Page           ixcPage = img.GetPage(0);
            IPXC_Image          pxcImg  = Parent.m_CurDoc.AddImageFromIXCPage(ixcPage);
            IPXC_ContentCreator CC      = Parent.m_CurDoc.CreateContentCreator();
            PXC_Rect            rcImg   = new PXC_Rect();

            CC.SaveState();
            {
                //Proportional resize rectangle calculation
                {
                    double k1 = nWidth / nHeight;
                    double k2 = (double)pxcImg.Width / pxcImg.Height;
                    if (k1 >= k2)
                    {
                        rcImg.top   = nHeight;
                        rcImg.right = nWidth / 2.0 + rcImg.top * k2 / 2.0;
                        rcImg.left  = nWidth / 2.0 - rcImg.top * k2 / 2.0;
                    }
                    else
                    {
                        rcImg.right  = nWidth;
                        rcImg.top    = nHeight / 2.0 + rcImg.right / k2 / 2.0;
                        rcImg.bottom = nHeight / 2.0 - rcImg.right / k2 / 2.0;
                    }
                }
                //Moving the image rectangle to the center

                PXC_Rect rcImage = new PXC_Rect();
                rcImage.right = 1;
                rcImage.top   = 1;
                PXC_Matrix matrix = Page.GetMatrix(PXC_BoxType.PBox_PageBox);
                matrix = auxInst.MathHelper.Matrix_RectToRect(ref rcImage, ref rcImg);
                CC.ConcatCS(ref matrix);
                CC.PlaceImage(pxcImg);
            }
            CC.RestoreState();
            Page.PlaceContent(CC.Detach());

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);

            return((int)Form1.eFormUpdateFlags.efuf_All);
        }
Ejemplo n.º 3
0
        static public void ConvertToImage(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocFromStringPath(Parent);
            }

            IIXC_Inst  ixcInst = Parent.m_pxcInst.GetExtension("IXC");
            IAUX_Inst  auxInst = Parent.m_pxcInst.GetExtension("AUX");
            IPXC_Pages pages   = Parent.m_CurDoc.Pages;
            IPXC_Page  Page    = pages[Parent.CurrentPage];
            double     nHeight = 0.0;
            double     nWidth  = 0.0;

            Page.GetDimension(out nWidth, out nHeight);
            uint                  cx      = (uint)(nWidth * 150 / 72.0);
            uint                  cy      = (uint)(nHeight * 150 / 72.0);
            IIXC_Page             ixcPage = ixcInst.Page_CreateEmpty(cx, cy, IXC_PageFormat.PageFormat_8ARGB, 0);
            IPXC_PageRenderParams param   = Parent.m_pxcInst.CreateRenderParams();

            if (param != null)
            {
                param.RenderFlags |= ((uint)PXC_RenderFlags.RF_SmoothImages | (uint)PXC_RenderFlags.RF_SmoothLineArts);
                param.SetColor(PXC_RenderColor.RC_PageColor1, 255, 255, 255, 0);
                param.TextSmoothMode |= PXC_TextSmoothMode.TSM_Antialias;
            }
            tagRECT rc = new tagRECT();

            rc.right  = (int)cx;
            rc.bottom = (int)cy;
            PXC_Matrix matrix = Page.GetMatrix(PXC_BoxType.PBox_PageBox);

            matrix = auxInst.MathHelper.Matrix_Scale(ref matrix, cx / nWidth, -cy / nHeight);
            matrix = auxInst.MathHelper.Matrix_Translate(ref matrix, 0, cy);
            Page.DrawToIXCPage(ixcPage, ref rc, ref matrix, param);
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_XDPI]       = 150;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_YDPI]       = 150;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_INTERLACE]  = 1;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_FILTER]     = 5;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_COMP_LEVEL] = 5;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_FORMAT]     = (uint)IXC_ImageFileFormatIDs.FMT_PNG_ID;
            IIXC_Image ixcImg = ixcInst.CreateEmptyImage();

            ixcImg.InsertPage(ixcPage, 0);
            string sPath = Path.GetTempFileName();

            sPath = sPath.Replace(".tmp", ".png");
            ixcImg.Save(sPath, IXC_CreationDisposition.CreationDisposition_Overwrite);
            Process.Start(sPath);

            ixcImg.RemovePageByIndex(0);
            ixcPage = ixcInst.Page_CreateEmpty(cx, cy, IXC_PageFormat.PageFormat_8Gray, 0);
            if (param != null)
            {
                param.SetColor(PXC_RenderColor.RC_PageColor1, 255, 255, 255, 255);
            }
            Page.DrawToIXCPage(ixcPage, ref rc, ref matrix, param);
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_XDPI]         = 150;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_YDPI]         = 150;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_YSUBSAMPLING] = 20;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_FORMAT]       = (uint)IXC_ImageFileFormatIDs.FMT_JPEG_ID;
            ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_JPEG_QUALITY] = 100;
            ixcImg.InsertPage(ixcPage, 0);
            sPath = sPath.Replace(".png", ".jpg");
            ixcImg.Save(sPath, IXC_CreationDisposition.CreationDisposition_Overwrite);
            Process.Start(sPath);
            Marshal.ReleaseComObject(Page);

            ixcImg.RemovePageByIndex(0);
            ixcPage = ixcInst.Page_CreateEmpty(cx, cy, IXC_PageFormat.PageFormat_8RGB, 0);
            for (int i = 0; i < pages.Count; i++)
            {
                Page = pages[(uint)i];
                Page.DrawToIXCPage(ixcPage, ref rc, ref matrix, param);
                ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_XDPI]   = 150;
                ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_YDPI]   = 150;
                ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_ITYPE]  = 1;
                ixcPage.FmtInt[(uint)IXC_FormatParametersIDS.FP_ID_FORMAT] = (uint)IXC_ImageFileFormatIDs.FMT_TIFF_ID;
                ixcImg.InsertPage(ixcPage);
                ixcPage = ixcInst.Page_CreateEmpty(cx, cy, IXC_PageFormat.PageFormat_8Gray, 0);
                Marshal.ReleaseComObject(Page);
            }
            sPath = sPath.Replace(".jpg", ".tiff");
            ixcImg.Save(sPath, IXC_CreationDisposition.CreationDisposition_Overwrite);
            Process.Start(sPath);


            Marshal.ReleaseComObject(pages);
        }