Skip to main content

I appreciate that with DSPs the answer is just to paint the image widget, however, this is for integration with a java(script) based graphics/graphing utility via JSON data output by a USP, so I can't do that. 

I have bitmap data loaded into the database using lfileload/raw, I am trying to convert this to a tag to display an image in HTML

<img src='data:image/bmp;base64, DATAGOESHERE'>

I have tried

variables
   raw v_raw
   string v_string
endvariables


    v_raw=$encode("URAW", fieldname)
    v_raw=$encode("BASE64", v_raw)
    v_string = $encode("USTRING", v_raw)
 

and then replacing DATAGOESHERE with v_string, this doesn't work (I've also tried it outputting a basic HTML file, so I know it's not anything further up the line which is at fault). 

I originally tried without the URAW encode, doesn't appear to make any difference. 

The data unloads to a bmp file using filedump/raw okay, so I am going to proceed with a (IMNSHO) 'bad' option of dumping the file into a folder in webapps, and then using the filename in the src, but this leaves temp files in the folder I will then have to tidy up, so I will jump at a solution which passes the bitmap data as, well, data. 

Regards, 

Iain



------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------

I appreciate that with DSPs the answer is just to paint the image widget, however, this is for integration with a java(script) based graphics/graphing utility via JSON data output by a USP, so I can't do that. 

I have bitmap data loaded into the database using lfileload/raw, I am trying to convert this to a tag to display an image in HTML

<img src='data:image/bmp;base64, DATAGOESHERE'>

I have tried

variables
   raw v_raw
   string v_string
endvariables


    v_raw=$encode("URAW", fieldname)
    v_raw=$encode("BASE64", v_raw)
    v_string = $encode("USTRING", v_raw)
 

and then replacing DATAGOESHERE with v_string, this doesn't work (I've also tried it outputting a basic HTML file, so I know it's not anything further up the line which is at fault). 

I originally tried without the URAW encode, doesn't appear to make any difference. 

The data unloads to a bmp file using filedump/raw okay, so I am going to proceed with a (IMNSHO) 'bad' option of dumping the file into a folder in webapps, and then using the filename in the src, but this leaves temp files in the folder I will then have to tidy up, so I will jump at a solution which passes the bitmap data as, well, data. 

Regards, 

Iain



------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------

Hi Ian,

Not need to convert to ustring. this old code seems to work.

It's a form width an html widget 

Variables
    raw rData
    string sBase64
EndVariables
lfileload/raw "d:\\temp\\image.bmp",rData
sBase64=$encode("BASE64",rData)
$fieldhandle("html.DUMMY")->$widgetoperation("loadHTML",$replace($test,1,"FILECONTENT",sBase64))
test:blockdata +
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <div>
      <p>From Artigues-pres-Bordeaux</p>
      <img src="data:image/bmp;base64,FILECONTENT" alt="French Flag" />
    </div>
  </body>
</html>+



------------------------------
Hortion Gilles
Dedalus Healthcare France
Artigues Pres Bordeaux FR
------------------------------