www.mxdraw.com
内容索引主面
前一个向上下一个
MxDrawXCustomFunction::Mx_DrawToJpg 方法

把指定区域的内容绘制一个jpg文件中。扩展名为bmp保存为bmp.

IDL
static BOOL Mx_DrawToJpg(IN CString sJpgFilePath, IN double dLbx, IN double dLby, IN double dRtx, IN double dRty, IN int iWidth = -1, IN int iHeight = -1, IN LONG* pBkColor = NULL);
参数 
说明 
IN CString sJpgFilePath 
Jpg文件名 
IN double dLbx 
输出范围的左下角坐标X,文档坐标系统 
IN double dLby 
输出范围的左下角坐标Y,文档坐标系统 
IN double dRtx 
输出范围的右上角坐标X,文档坐标系统 
IN double dRty 
输出范围的右上角坐标Y,文档坐标系统 
IN int iWidth = -1 
位图宽度方向的像素,是-1并iHeight不是-1,由高度和文档高宽算出,否则取系统默认值:1000 
IN int iHeight = -1 
位图高度方向的像素,是-1并iWidth不是-1, 由高度和文档高宽算出,否则取系统默认值:1000 
IN LONG* pBkColor = NULL 
位图的背影色,如果为NULL,取黑色为背景色 
hOcx 
当前控件名柄 

成功返回TRUE

例如: js程序

        function WriteJpg(obj)
        {
            var axMxDrawX = document.getElementById(obj);
            var viewBound = axMxDrawX.Call("Mx_GetViewCoord","");

            var jpgWidth = viewBound.AtDouble(3) - viewBound.AtDouble(1);
            var jpgHeight = viewBound.AtDouble(4) - viewBound.AtDouble(2);

            // 把jpg的宽度,高度,求文档坐标变成象素宽高.
            var jpgWidth = axMxDrawX.CallDoubleParam1("Mx_DocLongToViewCoord",jpgWidth);
            jpgWidth = jpgWidth.AtLong(1);
            var jpgHeight = axMxDrawX.CallDoubleParam1("Mx_DocLongToViewCoord",jpgHeight);
            jpgHeight = jpgHeight.AtLong(1);


            var savejpgParam =  axMxDrawX.Call("Mx_NewResbuf","");
            savejpgParam.AddString("F:\Temp\"+obj+".jpg");
            // 输入到jpg文件的图纸范围,就是当前视能看到范围
            savejpgParam.AddDouble(viewBound.AtDouble(1));
            savejpgParam.AddDouble(viewBound.AtDouble(2));
            savejpgParam.AddDouble(viewBound.AtDouble(3));
            savejpgParam.AddDouble(viewBound.AtDouble(4));

           // jpg文件的宽高.
            savejpgParam.AddLong(jpgWidth);
            savejpgParam.AddLong(jpgHeight);



            var ret = axMxDrawX.CallEx("Mx_DrawToJpg",savejpgParam);
        }

例如: C#代码.

        private void WriteJpg()
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "jpg 文件(*.jpg)|*.jpg";

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MxDrawUiPrPoint getpoint = new MxDrawUiPrPoint();
            getpoint.message = "选择范围第一个点";
            if (getpoint.go() != MCAD_McUiPrStatus.mcOk)
            {
                return;
            }

            MxDrawResbuf param = new MxDrawResbuf();

            param.AddDouble(getpoint.value().x, -10);
            param.AddDouble(getpoint.value().y, -10);

            MxDrawResbuf retParam = (MxDrawResbuf)axMxDrawX1.CallEx("Mx_GetCorner", param);

            if (retParam.AtString(0) != "Ok")
            {

                return;

            }

            MxDrawResbuf savejpgParam = new MxDrawResbuf();
            savejpgParam.AddString(sfd.FileName, -10);
            savejpgParam.AddDouble(getpoint.value().x, -10);
            savejpgParam.AddDouble(getpoint.value().y, -10);

            savejpgParam.AddDouble(retParam.AtDouble(1), -10);
            savejpgParam.AddDouble(retParam.AtDouble(2), -10);

            // jpg文件的宽高.
            savejpgParam.AddLong(500, -10);
            savejpgParam.AddLong(500, -10);

            MxDrawResbuf ret = (MxDrawResbuf)axMxDrawX1.CallEx("Mx_DrawToJpg", savejpgParam);

            if(ret != null && ret.AtString(0)== "Ok")
            {
                MessageBox.Show("输出jpg文件成功");
            }

        }

例如: Qt程序

    QAxObject *param  =  ui->axWidget->querySubObject("NewResbuf");

    param->dynamicCall("AddString(const QString&)",sFileName);

    param->dynamicCall("AddDouble(const double&)",dLbx );

    param->dynamicCall("AddDouble(const double&)",dLby  );

    param->dynamicCall("AddDouble(const double&)",dRtx  );

    param->dynamicCall("AddDouble(const double&)",dRty  );

    QAxObject *ret  =ui->axWidget->querySubObject("CallEx(const QString&,QVariant)","Mx_DrawToJpg",param->asVariant());
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!