 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bruno G. Guest
|
Posted: Thu Jan 29, 2004 2:56 pm Post subject: Convert a String to a Stream |
|
|
Hi!
I'm loading a bitmap image from its text representation in a DFM file -
Everything is working, but it's way too slow.
What I do is this: Trim extra information from the Picture.Data string - BMP
start with 'BM' or 424D. Convert the string to a stream by converting each
2 characters pair ('42', '4D', etc.) to its decimal equivalent (66, 77,
etc.) and putting it into a TMemoryStream. I can then use the LoadFromStream
method to display the image.
This works fine, but it takes forever!
I'm sure there is a way to convert the whole string to a stream in a simple
and fast way, but I can't find it.
Anyone has a suggestion?
Thanks in advance.
Bruno G.
Montreal, QC, Canada
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Thu Jan 29, 2004 3:36 pm Post subject: Re: Convert a String to a Stream |
|
|
Bruno G. wrote:
| Quote: | I'm loading a bitmap image from its text representation in a DFM file -
Everything is working, but it's way too slow.
|
You might want to take a look at ObjectTextToBinary and
TParser.HexToBinary, and HexToBin. Those are the routines the run-time
library can use to make the same conversion you're doing. The
text-to-binary conversion is actually performed by the compiler when you
create your program, so no conversion takes place when loading the form
at run time.
--
Rob
|
|
| Back to top |
|
 |
Bruno G. Guest
|
Posted: Thu Jan 29, 2004 4:32 pm Post subject: Re: Convert a String to a Stream |
|
|
| Quote: | Bruno G. wrote:
I'm loading a bitmap image from its text representation in a DFM file -
Everything is working, but it's way too slow.
|
Rob Kennedy wrote:
| Quote: | You might want to take a look at ObjectTextToBinary and
TParser.HexToBinary, and HexToBin.
|
WOW! HexToBin was exactly what I needed... Loading one DFM (with two big
image list) went from 8m46s to only 27s...
Thanks!!
Bruno G.
Montreal, QC, Canada
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|