Exemple #1
0
        public static void SaveImage(AxPXV_Control axPXV_Control1, Workspace workspace_ob, string imageDest, IXC_ImageFileFormatIDs format)
        {
            IXC_PageFormat nFormat  = IXC_PageFormat.PageFormat_8Indexed;
            IIXC_Inst      inst     = (IIXC_Inst)axPXV_Control1.Inst.GetExtension("IXC");
            IIXC_Page      page_ixc = inst.Page_CreateEmpty((uint)workspace_ob.field_ex.width, (uint)workspace_ob.field_ex.heigth, nFormat, 324345);

            page_ixc.PaletteSize = (uint)workspace_ob.keys.Count;
            for (int i = 0; i < workspace_ob.field_ex.width; i++)
            {
                for (int j = 0; j < workspace_ob.field_ex.heigth; j++)
                {
                    Color clr  = workspace_ob.field_ex.clr_fild[i][j];
                    uint  clgr = (uint)((byte)(clr.R) | ((UInt16)((byte)(clr.G)) << 8)) | (((UInt32)(byte)(clr.B)) << 16);
                    page_ixc.SetPixel(i, j, (uint)clgr, (uint)IXC_ColorFlags.Color_AddColor);
                }
            }
            page_ixc.ConvertToFormat(nFormat);
            IIXC_Image img = inst.CreateEmptyImage();

            img.InsertPage(page_ixc);
            page_ixc.set_FmtInt((uint)IXC_FormatParametersIDS.FP_ID_FILTER, 0);
            page_ixc.set_FmtInt((uint)IXC_FormatParametersIDS.FP_ID_FORMAT, (uint)format);
            page_ixc.set_FmtInt((uint)IXC_FormatParametersIDS.FP_ID_ITYPE, 16);
            page_ixc.set_FmtInt((uint)IXC_FormatParametersIDS.FP_ID_COMP_LEVEL, 2);
            page_ixc.set_FmtInt((uint)IXC_FormatParametersIDS.FP_ID_COMP_TYPE, 0);
            img.Save(imageDest, IXC_CreationDisposition.CreationDisposition_Overwrite);
        }
Exemple #2
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);
        }