Picture processing in Dynamics AX

Source: Internet
Author: User

1. Read the image file locally and determine if the format is compliant.

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. Save the pictures in AX to a local folder

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. Picture zoom is displayed on the control.

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);//photo is bitmap control

4. cut the picture, the control window showing the picture cannot be obscured by other windows.

Container rect;

rect = Winapi::getwindowrect (This.hwnd ());// Gets the screen coordinates of the picture control

int left,top;

left = Conpeek (rect,1);

top = Conpeek (rect,2);

Image = new Image ();

Image.capturescreen (left,top,width,height);// cut according to coordinates and size, this method can also be used for screen

5. export pictures to the specified folder for batch image export.

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+= "\";// If you select a desktop, add \

path + = filename;

Image.saveimage (path);

Additional: gets the number of records selected by the user, taking empltable as an example:

For (Emp=empltable_ds.getfirst (1) Empltable_ds.getfirst (1): Empltable_ds.cursor (); Emp;emp=empltable_ds.getnext ())

{

Do something

}

Picture processing in Dynamics AX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.