Board index » delphi » BitMaps in Shared Memory

BitMaps in Shared Memory


2004-10-20 08:08:13 PM
delphi10
Does anyone know if it is possible to load a bitmaps into Shared Memory?
I need to access them from a DirectShow filter, and this seems the best way
for me to do it.
My bitmaps are being written into a TbitMap, but I don't know what to do
next!
I've found several articles referring to shared memory mapping etc., but
none of them mention or give examples of loading a bitmap.
Any help is much appreciated,
Ben.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004
 
 

Re:BitMaps in Shared Memory

Ben writes:
Quote
Does anyone know if it is possible to load a bitmaps into Shared
Memory?

I need to access them from a DirectShow filter, and this seems the
best way for me to do it.

My bitmaps are being written into a TbitMap, but I don't know what to
do next!

I've found several articles referring to shared memory mapping etc.,
but none of them mention or give examples of loading a bitmap.

Any help is much appreciated,

Ben.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004
You could indeed use a memory mapped file. It basically creates a
commonly accessible chunk of memory you can read/write to from a
pointer.
However, on creation of this common memory, the size is fixed. You
can't increase it, you would have to release it, and have everything
re-open access to it to see a newly sized file.
Its fast to read from, but that in-flexibility about its size is the
point you have to consider. If you know the size you require, and
don't need to increase, at the time you are reading the file in, then
its fine :)
API Calls to examine:
CreateFileMapping
MapViewOfFile
UnmapViewOfFile
Regards,
Scott :)
 

Re:BitMaps in Shared Memory

Thanks Scott,
Do you know where I can find sample code?
I can find Mem Mapping but writing a bitmap to it isn't mentioned.
Any thoughts?
Thanks again,
Ben
"Scott Price" <XXXX@XXXXX.COM>writes
Quote
Ben writes:

>Does anyone know if it is possible to load a bitmaps into Shared
>Memory?
>
>I need to access them from a DirectShow filter, and this seems the
>best way for me to do it.
>
>My bitmaps are being written into a TbitMap, but I don't know what to
>do next!
>
>I've found several articles referring to shared memory mapping etc.,
>but none of them mention or give examples of loading a bitmap.
>
>Any help is much appreciated,
>
>Ben.
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (www.grisoft.com).
>Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004

You could indeed use a memory mapped file. It basically creates a
commonly accessible chunk of memory you can read/write to from a
pointer.

However, on creation of this common memory, the size is fixed. You
can't increase it, you would have to release it, and have everything
re-open access to it to see a newly sized file.

Its fast to read from, but that in-flexibility about its size is the
point you have to consider. If you know the size you require, and
don't need to increase, at the time you are reading the file in, then
its fine :)

API Calls to examine:

CreateFileMapping
MapViewOfFile
UnmapViewOfFile


Regards,


Scott :)
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004
 

Re:BitMaps in Shared Memory

Ben writes:
[]
Quote
Do you know where I can find sample code?
I can find Mem Mapping but writing a bitmap to it isn't mentioned.
www.djpate.freeserve.co.uk/GetCode.htm
Take a look at MapFiles - you will need to do the bitmap stuff, though.
Cheers,
David
 

Re:BitMaps in Shared Memory

Thanks David,
Yep........I've got it.
Good work from Debs, and I am getting somewhere with it.
Cheers,
Ben.
"David J Taylor" <XXXX@XXXXX.COM>writes
Quote
Ben writes:
[]
>Do you know where I can find sample code?
>I can find Mem Mapping but writing a bitmap to it isn't mentioned.

www.djpate.freeserve.co.uk/GetCode.htm

Take a look at MapFiles - you will need to do the bitmap stuff, though.

Cheers,
David

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.779 / Virus Database: 526 - Release Date: 19/10/2004
 

Re:BitMaps in Shared Memory

Quote
>Do you know where I can find sample code?
>I can find Mem Mapping but writing a bitmap to it isn't mentioned.

www.djpate.freeserve.co.uk/GetCode.htm

Take a look at MapFiles - you will need to do the bitmap stuff, though.
Likewise, JCL has a few stream and file based mem mapping class in
JclFileUtils unit I believe.
Regards,
Scott :)
 

Re:BitMaps in Shared Memory

Quote
Do you know where I can find sample code?
I can find Mem Mapping but writing a bitmap to it isn't mentioned.
No problem.
Its a pointer, so basically you can use something like the Move method
to copy data from one pointer to another.
Move(pBmpData^, pMemMapping^, iBmpDataSize);
CreateFileMapping is the first call, then MapViewOfFile is the call
that actually returns you the useful pointer. It is this pointer you
can use in calls to things like Move().
PS Move is a bad name, it actually copies the number of bytes
specified from one location to another.
Regards,
Scott :)
Always worth checking out the JCL:
sourceforge.net/projects/jcl/
JclFileUtils.pas