如何指定范围保存jpg?
C#开发|冯美娟|2018-07-24 15:30
-
回答:
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); param.AddDouble(getpoint.value().y); MxDrawResbuf retParam = (MxDrawResbuf)axMxDrawX1.CallEx("Mx_GetCorner", param); if (retParam.AtString(0) != "Ok") { return; } MxDrawResbuf savejpgParam = new MxDrawResbuf(); savejpgParam.AddString(sfd.FileName); savejpgParam.AddDouble(getpoint.value().x); savejpgParam.AddDouble(getpoint.value().y); savejpgParam.AddDouble(retParam.AtDouble(1)); savejpgParam.AddDouble(retParam.AtDouble(2)); // jpg文件的宽高. savejpgParam.AddLong(500); savejpgParam.AddLong(500); MxDrawResbuf ret = (MxDrawResbuf)axMxDrawX1.CallEx("Mx_DrawToJpg", savejpgParam); if(ret != null && ret.AtString(0)== "Ok") { MessageBox.Show("输出jpg文件成功"); } }