Read an external bitmap file

atankersleyatankersley Member Posts: 32
edited 2008-01-31 in Navision Attain
I have item pictures for 20,000 items. What I want to do is store the pics in an external file and read them into the item card on the fly for display. I thought I could use an instream, but I am hung up on how to read the bmp file with the instream I created from the Item.Picture.CREATEINSTREAM(). I would be very thankful for any insite on this.
tank

Answers

  • SavatageSavatage Member Posts: 7,142
    http://www.mibuso.com/forum/viewtopic.php?t=16184

    they key here is to have the picture name the same as the item no.
    On the Item Picture Form 
    
    OnAfterGetRecord() 
    Code: 
    SETRANGE("No."); 
    
    IF EXISTS ('P:\BMP\'+"No."+'.BMP') 
    THEN 
    Picture.IMPORT('P:\BMP\'+"No."+'.BMP',FALSE); 
    CALCFIELDS(Picture); 
    
    That's it - now your pic will show.
    

    note p:\bmp\ is the drice & directory where we store our pictures. change it to fit your drive & directory names

    as Kriki or Alex stated in another post - if you are using ver5 you can link the pic just as you link different external docs.
  • SavatageSavatage Member Posts: 7,142
    note adding CLEAR(Picture);

    OnModify of the item table. insures the pic won't be saved while viewing the pic and someone makes a change on that item.

    Note: If you modified your item card to show the picture in a picture box then add the code to the item card not the item picture form
  • SavatageSavatage Member Posts: 7,142
    last thought: assuming you're never imported pictures then go ahead and use the above code. If you have already imported pictures and want to clear them from Item.Picture blob without having to go one by one.

    create a report based on the item table.
    OnAfterGetRecord()
    IF Item.Picture.HASVALUE
     THEN 
      CLEAR(Item.Picture);
       Item.MODIFY;
    

    did i miss anything? :-k
  • SavatageSavatage Member Posts: 7,142
    OOOH!

    If you don't have access to the code on the forms & tables.

    You can Create a Report based on the item table.
    View the sections and put 1 big picture box with sourexp as Picture

    add the code
    OnAfterGetRecord()
    IF EXISTS ('P:\BMP\'+"No."+'.BMP') 
    THEN 
    Picture.IMPORT('P:\BMP\'+"No."+'.BMP',FALSE); 
    CALCFIELDS(Picture);
    

    Now on the item card add a command button
    PushAction:RunObject
    The object will be this report.

    Unfortunately at this point you will need to transfer the parameter of which item your on tot he report, which will require some more coding but if you ok with manually entering the No - this way will work too

    Not as pretty & nice thou.
  • atankersleyatankersley Member Posts: 32
    Thanks alot Savatage. Your code worked perfectly.
    tank
Sign In or Register to comment.