BitMaps from memory revisited

BitMaps from memory revisited

Postby rhlawek » Tue Jun 10, 2014 9:25 pm

Antonio,

I use a remote database which has two fields, the second field is a blob that contains a bitmap, which could be .bmp, .jpg, or .png. The first field is just a reference name. I get the data back as an array, then just use SetArray() to load into xbrowse.

When I create an xbrowse the bitmap is handled mostly correctly, in that it displays in the grid. I need to take that same bitmap out of the array and simply display it in a window using an appropriate control (TBitmap, TImage, ?) without ever writing the bitmap to disk. There are a large number of examples that show how to load a bitmap from a file on disk, and an equally large number showing how to load a bitmap from a resource, but there are no examples that I can find that show how a bitmap as I have described can be displayed directly from memory without ever putting the file on disk.

I know this can be done, xbrowse does it itself when :nEditType is set to EDIT_BUTTON on the field with the bitmap, the default behavior of pressing the button is to open a dialog that displays the bitmap. If I could figure out what is being called by default to manipulate and display that data I could probably figure this out from there, but a simple example would work better.

Can I please get an example that shows how to take a bitmap that is in memory either as a harbour variable, or is in a database where it could be accessed using alias->blobname, attach that to an appropriate control and get it to display in either a window or a dialog. I know I can do this by first writing the blob to disk, then reloading from disk, but I have no desire to do this. And, in my case, it will never ever exist as a resource embedded in an .rc file, so examples for loading from resource don't help.

Robb
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: BitMaps from memory revisited

Postby rhlawek » Tue Jun 10, 2014 10:13 pm

I finally found what I was after reading TBitmap class source, there is a very useful LoadFromString() method that doesn't appear to be documented. It shows not only how to solve my current need, but also illustrates how to do the behind the scenes manipulation.

I can make progress again.

Robb
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: BitMaps from memory revisited

Postby Antonio Linares » Wed Jun 11, 2014 7:50 am

Robb,

Also you can create a bitmap from memory (and fill its data in) using C language as we do in:

fwh\source\function\bitmaps.c
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41394
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: paquitohm and 17 guests