After reviewing the code at topwiz, I decided to construct the bmp myself from scratch...
A great description of the BMP file format can be found here: Bits to Bitmaps: A simple walkthrough of BMP Image Format | by Uday Hiwarale | System Failure | Medium
To do this, I initialize an array the same size as my signature data which would always be the same size, and all the points would already initialize to 0:
int li_points[512,256]
I then set the points as I would a graph object. Since my BMP will be monochrome, I only have to set each point to 1. (Someone more ambitious could set each point to the integer (decimal) value of the pixel to represent the color.) Then finally convert everything to a byte array, then a blob:
ll_byte_count = 1
//CONSTRUCT HEADER
is_header= '424D3E400000000000003E00000028000000000200000001000001000100000000000000000000000000000000000000000000000000FFFFFF0000000000'
For li_n = 1 to LEN(is_header) step 2
ls_testvalue = MID(is_header, li_n, 2)
li_byte = of_hex_to_int(ls_testvalue) // a simple routine that returns the decimal value from hex.
lbyte_array[ll_byte_count] = byte(li_byte)
ll_byte_count = ll_byte_count + 1
NEXT
ls_binary = ''
//My BMP is monochrome, so only one bit per pixel, but the pixel data still has to be stored by byte in the blob.
FOR li_rowY = 1 to 256
FOR li_colX = 1 to 512
li_testvalue = li_points[li_colX, li_rowY]
//just-in-case
if isNull(li_testvalue) or ( li_testvalue <> 1 and li_testvalue <> 0 ) then
li_testvalue = 0
end if
ls_binary = ls_binary + String(li_testvalue)
if Len(ls_binary) = 8 then
li_byte = this.of_binary_to_int( ls_binary) // a simple routine that returns the decimal value from a string that represents a binary number. e.g. '10010000'.
lbyte_array[ll_byte_count] = byte(li_byte)
ll_byte_count = ll_byte_count + 1
ls_binary = ''
end if
NEXT
NEXT
//CONVERT INTO BLOB
a = lbyte_array
lblob_final = Blob(a)
//lbob_final should now be a properly constructed BMP
p_1.SetPicture ( lblob_final)