StrataFrame Forum

Convert a path of a image on the db to a image on the BO?

http://forum.strataframe.net/Topic16554.aspx

By Fabian R Silva, - - 5/23/2008

What is the best way to show a image that I have to convert from a path on the db to a image on my UI? I think about a custom readonly property that read it, serialize it and show it,





when I don´t like to load everytime a property if it was filled previously I do:



private _mycustomImage as image

property mycustomimage

get

if _mycustomimage is nothing then

'-- read image from db and convert it to a image...

_mycustomImage = imagethatIgetfrompath

endif

return _mycustomimage

end get

end property



but this is not possible for a custom property on BO



I not sure about Custom Code on BOM or what solution is the best recommendation.



Thanks
By Trent L. Taylor - 5/26/2008

We actually have a portion of our medical application that is a document and imaging product that allows images to be stored in either a database or on disk (if they use SQL Express then this would be the road they take).  We try not to serialize anything in regards to images as it really bloats the file and makes it larger.  So when we use the database side, we store the image as a JPG, PNG, etc. as a byte array in a VarBInary(MAX) field.  But when pulling form disk, just give the bitmap the path:

New Bitmap("c:\myimage.jpg")

We have a shared class that gives us all of the logical installed paths (this path can be set by the end-user) so we add that logic in as well which can be placed in the BO (custom code property).