zoukankan      html  css  js  c++  java
  • Dynamics AX 中的图片处理

     

    1.从本地读取图片文件,并判断格式是否附合要求。

     

        FilenameFilter filter = ['Image Files','*.bmp;*.jpg;*.gif;*.jpeg'];

        BinData binData = new BinData();

        str extention, path, nameOfFile;

        Container imageContainer ;

        imageFilePathName = WinAPI::getOpenFileName(element.hWnd(),filter,'', "@SYS53008", '','');

        if (imageFilePathname && WinAPI::fileExists(imageFilePathName))

        {

            [path, nameOfFile, extention] = fileNameSplit(imageFilePathName);

            if (extention == '.jpg')

            {

                binData.loadFile(imageFilePathName);

                imageContainer = binData.getData();

     

            }

            else

            {

                throw error("@SYS89176");

            }

        }

     

    2.AX中的图片保存到本地文件夹

        str path;

        FilenameFilter filter = ['Image Files','*.jpg'];

        CompanyImage companyImage;

        Image image;

        DialogBox dialogBox;

     

        ;

       

       

            path = WinAPI::getSaveFileName(0,filter,'','','','filename',0);

            if(path)

            {

                image = new Image();

                image.setData(companyImage.Image);

                 if(WinAPI::fileExists(path))

                {

                     dialogBox = new DialogBox(DialogBoxType::YesNoBox,strfmt("@HPH243",path),'','',DialogButton::Yes);

                     if(DialogButton::Yes == dialogBox.retval())

       image.saveImage(path);

         }

         else

      {

      image.saveImage(path);

      }

     }

    3.图片缩放显示在控件上。

      image = new Image();

      image.setData(imageContainer);

     

                w = image.width()*sel/100;

                h = image.height()*sel/100;

     

                image.resize(w,h,InterpolationMode::InterpolationModeDefault);

     

                Photo.image(image); //Photobitmap控件

    4.图片的剪切,显示图片的控件窗口不能被其他窗口遮挡。

     Container rect;

     rect = WINAPI::getWindowRect(this.hWnd());//获取图片控件的屏幕坐标

     int left,top;

     left = conpeek(rect,1);

     top = conpeek(rect,2);

     image = new Image();

            image.captureScreen(left,top,width,height);//根据坐标和大小进行剪切,该方法同样可以用来进行屏幕截图

    5.导出图片到指定文件夹,适用于批量图片导出。

     str path;

     Image image;

     str filename = "test.jpg";

     image = new Image();

     image.setData(imageContainer );

     path = WinAPI::browseForPath(element.hWnd(),'');

     if(substr(path ,strlen(path)-1,1)!="\")

                path+="\";//如果选择的桌面,则要加上

     path += filename;

     image.saveImage(path);

    附加: 获取用户选中的多条记录,以EmplTable为例:

     for(emp=EmplTable_ds.getFirst(1) EmplTable_ds.getFirst(1):EmplTable_ds.cursor();emp;emp=EmplTable_ds.getNext())

            {

                //do something

            }

  • 相关阅读:
    斯巴鲁汽车 技术文档下载方法
    博客园 Mac Windows Linux 客户端 源码 electron 开发
    博客园 Mac客户端 1.0 源码
    博客园 Mac客户端 2.0-Beta
    Python数据分析的库
    排版助手Gidot
    离线下载pip包进行安装
    Anaconda+用conda创建python虚拟环境
    ? Install Telegram on Ubuntu via PPA
    使用BeautifulSoup删除html中的script、注释
  • 原文地址:https://www.cnblogs.com/KobeZhang/p/4466291.html
Copyright © 2011-2022 走看看