Ok, the following works to write the image data to a stream and save the stream to JPG and PNG files (Thanks, Jim):
cSQL="SELECT GetAs(bgImage, 'JPEG'), GetAs(fgImage, 'PNGf') FROM GSBackgrounds where gsBgID = 1"
RS101.Open(cSQL,cConnFMS,3,3)
;read back out as binary stream
Stream = CreateObject("ADODB.Stream")
Stream.Type = 1
;write bg (jpg) to file
Stream.Open()
Stream.Write( RS101.Collect("bgImage") )
Stream.SaveToFile("c:\bg1.jpg",2)
Stream.close()
;write fg (png) to file
Stream.Open()
Stream.Write( RS101.Collect("fgImage") )
Stream.SaveToFile("c:\fg1.png",2)
Stream.close()
Stream=0
RS101.Close()
And after Tony's tips, this will read the stream directly to a buffer:
Stream.Open()
Stream.Write( RS101.Collect("bgImage") )
Stream.Position = 0
x = Stream.Read()
bJPG = BinaryAllocArray(x)
;confirmed to work, by writing the buffer to a file. Resulting file is the same as the Stream.SaveToFile())
BinaryWrite(bJPG, "c:\jpg bb.jpg")
Thank you,
Paul