web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Convert System.Drawing.Image to Container

(0) ShareShare
ReportReport
Posted on by 3,262

Hi

Get System.Drawing.Image from referenced assembly and want to save it to table Container direct, means without saving to file first.

img = qRCodeEncoder.Encode(HSC_TestQRCode.Text); Type System.Drawing.Image

imgB = new System.Drawing.Bitmap(img);

imgConv.importBitmap(imgB.GetHbitmap()); Type Image

c = imgConv.getData();

Line importBitmap() with error: Image (object), method importBitmap called with invalid parameters.

Thanks for help

Jan

*This post is locked for comments

I have the same question (0)
  • rc123 Profile Picture
    5 on at

    I am currently trying to accomplish this with no luck, trying to add a custom image to the Purchase Order form

    I have a System.Drawing.Bitmap object that has a working image in it (i've confirmed this and it isnt the issue)

    I added a new field to the PurchPurchaseOrderHeader temp table of a type container (we'll call it CustomImage).

    Now I'm trying to insert that system.drawing.bitmap object to that new field in the PurchPurchaseOrderHeader.

    If I try:

    System.Drawing.Bitmap imgBitmap;

    imgBitmap = *assign image to imgBitmap*

    purchPurchaseOrderHeader.CustomImage = imgBitmap,

    I get the "Operand types are not compatible with the operator" error.

    I've tried to create an "anytype" object and assign the image to that, then do purchPurchaseOrderHeader.CustomImage = anytypeobject, but that isn't populating the field

    Any help would be appreciated

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi Jan,

    For save in container:

    static void BinDataTest(Args _args)

    {
        BinData b = new BinData();
        Container c;
        b.loadFile(@"C:\img.bmp");
        info(int2str(b.size()));
        c = b.getData();
        b = new BinData();
        b.setData(c);
        info(int2str(b.size()));
        b.saveFile(@"D:\img.bmp");
    }


  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi Jan,

    For save in table:

    static void ImageField(Args _args)
    {
        BinData binData = new BinData();
        A_ImageTable table;
        container imageContainer;
        str imageFilePathName;
        imageFilePathName="C:\\Users\\Public\\Desktop\\img.jpg";
        if ( WinAPI::fileExists(imageFilePathName))
        {
           binData.loadFile(imageFilePathName);
           imageContainer = binData.getData();
           table.Image = imageContainer;
           table.insert();
        }
    }


  • Hossein.K Profile Picture
    6,648 on at

    Hi,

    Your problem is solved?Right?

  • Jan M. Profile Picture
    3,262 on at

    Hi Hossein

    That sould answer rc123. My original question was from 2014 and I don't remember what I did....

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans