Link to home
Start Free TrialLog in
Avatar of thales042397
thales042397

asked on

displaying bitmaps from memory

I have a bitmap in memory in the correct format stored in an array and I wish to display it as quickly as possible on the screen. At present I copy the array to disk and display it after doing a bitmap.loadfromfile this is however to slow for my purpose. Please advise
Avatar of StevenB
StevenB

Presumably your bitmap is stored in A TBitmap in memory. To disply this on the screen simply use the Draw method of a canvas:

1) Create the component on which you wish to display the bitmap
2) With the component call Canvas.Draw(X,Y,Bitmap) Where X and Y are the coordinates where you want the image.

If your bitmap in memory is not stored in a TBitmap then the best approach is to get it into one as soon as possible:

1) Create a TBitmap
2) Loop through the array which holds the image and use the Pixels property of the Bitmap's Canvas to copy the bitmap into the TBitmap pixel at a time.
3) Display the bitmap as above.

  Hope this helps, if you want more info then add a comment,

  Steven


Avatar of thales042397

ASKER

Thanks steve,

Is it however not possible to somehow Point Tbitmap to the image in memory because time is of the essense, rather than copying  the info from one point in memory to the next and then displaying



 OK, firstly, I am wondering where your bitmap is coming from. If at all possible I would be tempted to suggest that you ensure that it gets into a TBitmap, we are using Delphi afterall. Perhaps some more info on what you are trying to do would help.

  If you cannot get the TBitmap component involved then you will probably be looking to use the API calls CreateBitmap or CreateCompatibleBitmap and SetDIBits calls. These allow you to turn a block of data in memory into a bitmap and display them. I won't go into this in too much depth here, there is online help.

  If you tell me more about what you are trying to do, how the bitmap is being generated and what format it is being stored in then I may be able to help you better. What sort of handle do you have on the bitmap?

  Steven.
Ok, let me start at the begining. I have a custom made frame grabber in the pc. I access the frame grabber as a block of memory between d000 and dfff which gives me 65k worth of data. The format of the  received data from the frame grabber is YUV. I copy the frame grabber memory location to an array in memory, approximatelly 8 times (65k*8) to get the entire image, after which I convert the image to RGB and add bitmap info for display purposes. What I really want is to display the image as close to realtime as possible thus the need for a fast method of display.

Thanks,
Kevin
 If I understand you correctly then you have a handle on the bitmap. Have you looked at the API call GetDIBits, I think it may be what you're looking for. There are lots of functions for Blitting bitmaps to devices, depending on what sort of handles you have.

If I've understood this, you have a memory image of a valid bitmap file, and you need to have windows recognize your raw data as a bitmap and then display it, without going through too many conversions/data moves.

If so, let me know and I'll have a solution for you in a day or so.

Regards,

Erik.
If Eric Sperling could please attempt the question as he offered in the last response I would really appreciate it

Thanks,
Kevin.
Just to be sure. Your memory image is in the exact format of a bitmap file. Right?

Erik.

Completely off the subject for a moment:
Kevin, are you the same Kevin that I know from the company
Thales Advanced Engineering, or is it just a coincedence?
Couldn't you copy the data straight from the frame grabber
into a pre-made TBitmap, so your YUV to RGB conversions within
the TBitmap, then display it.  YUV is the same width as RGB, is
it not...therefore each TBitmap pixel will hold YUV data (though
in that format the Bitmap would look odd) and you could just do the conversions in the TBitmap (to be redundant).
ASKER CERTIFIED SOLUTION
Avatar of sperling
sperling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Eric I will be trying your proposed unit today and Will post a response.

To Gysbert1

Thales is the same company but I am a different kevin. Drop me a note and I will provide more info.
Thanks again the results were perfect
Hi Kevin,
what's your email address?
I couldn't seem to find it in your customer info...
To gysbert1

My email address is support-desk@thales.co.za

Hope to hear from you soon

Kevin.