2 Replies Latest reply: Jul 4, 2012 12:03 PM by Fonarix RSS

    Picture preview control

    Fonarix Community Member

      I'm beginner in AI SDK, and can't find any control to draw image at ADM dialog.

      All I need is just render a picture from png or jpeg file or from memory on a top half of ADM dialog and CS4 SDK.

      I suppose I have to use IADMDrawer, ADMImageSuite...

      Or what is the best?


      Thanks beforehand.

        • 1. Re: Picture preview control
          A. Patterson Community Member

          If you just want something that displays an image, create the control with kADMPictureStaticType. Then you can use IADMItem::SetPictureID() to specify a resource ID to display.


          If you need something more complicated, inherit from IADMItem and override the Draw() method. You use the IADMDrawer that method provides to draw an ADMImageRef (and you specify where). If you can use static images, you're better off (you can cache the ADMImageRef handles and draw them when you want them). An ADMImageRef you'll have to build yourself (with SetPixel, see ADMImage.h) but if you have PNG & JPGs you want to use, I think ADMIcon.h has loading functions you can use to pull them from resource files. IADMDrawer should be able to render them as well.

          • 2. Re: Picture preview control
            Fonarix Community Member

            Thank you for your help. I just for testing purposes used this code:


            void ThisIsATestDialog::Draw(IADMDrawer drawer)


                std::vector<unsigned char> bytes;

                int width = 0;

                int height= 0;

                int bpp   = 0;

                int pitch = 0;

                std::string imageFile("C:\\default.bmp");


                bool bRet = LoadImageFromDisk(imageFile, bytes, width, height, bpp, pitch);


                ADMImageRef imageRef = NULL;

                if (bytes.size())

                    imageRef = sADMImage->Create(width, height, kADMImageHasAlphaChannelOption);


                if (imageRef)


                    ADMBytePtr pBytes = sADMImage->BeginBaseAddressAccess(imageRef);

                    int bytesPerPixel = bpp/8;


                    if (pBytes)

                    for (long k=0; k<height; k++)


                        int currRow = k*pitch;

                        for (long m=0; m<width; m++)


                            int pixelIndex = currRow + m*bytesPerPixel;

                            *(pBytes++) = bytes[pixelIndex+0];

                            *(pBytes++) = bytes[pixelIndex+1];

                            *(pBytes++) = bytes[pixelIndex+2];

                            if (32 == bpp)

                                *(pBytes++) = bytes[pixelIndex+3];


                                *(pBytes++) = 0xFF;






                IADMPoint topLeftPoint(0, 0);

                drawer.DrawADMImage(imageRef, topLeftPoint);


                // Draw test figure


                IADMRect rect(0, 0, 50, 50);





            I'll investigate, maybe Illustrator has a sute for jpg/png/pdf image loading...