Recently I have some requirement to extract Navision item picture to web front application and with Navision 2009 I could store not only BMP format but many other format namely, JPEG, TIFF, PNG and etcetera.  This is indeed is great improvement in Navision 2009, since BMP format is not the best format due the size of the space. Now, I have a little problem with the format diversity on how to recall the image format type. I need find out the format type because the web pages require the right content type before it can display correctly.

After some study and research, finally I can make a simple function in Navision C/AL to detect the image format type directly from the blob image field. Basically some bytes at the beginning of the image store the image format information. So, I need the first 4 characters from the BLOB image and do checking with it.  The function below detects some major image format and could be extended to detect others whenever it is necessary.

Content Type Function Detector

Below C/AL code  is using detector function for displaying the content type format of item picture:

                            

l_recItem.CALCFIELDS(Picture);
IF l_recItem.Picture.HASVALUE THEN BEGIN
   l_recItem.Picture.CREATEINSTREAM(l_instreamBigData);
   l_instreamBigData.READTEXT(l_textLen4);
   l_textContentType := l_cduGenFunction.GetImageContentType(l_textLen4);
   Message(’Image Format is : ‘ + l_textContentType);
END;

2 Responses to “How to find out Picture Image Format in Navision 2009”

  1. Ralph Hathaway Says:

    Andy,
    We have recently upgraded to NAV2009. We were under the impression that the Item.Picture field was able to accept formats other than .BMP (We store our prints in this field to be printed with our work orders). Our VAR told us the only format possible with 2009 was .BMP. You indicated above that other formats were possible - Am I missing something?

  2. mandyk Says:

    Ralph,
    Sorry for this, I didn’t mentioned that it is only applicable for Nav RTC 2009. Meanwhile the Nav client classic still stick with BMP which is carried from the past version.

Leave a Reply

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word