BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert a String to a Stream

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Bruno G.
Guest





PostPosted: Thu Jan 29, 2004 2:56 pm    Post subject: Convert a String to a Stream Reply with quote



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





PostPosted: Thu Jan 29, 2004 3:36 pm    Post subject: Re: Convert a String to a Stream Reply with quote



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





PostPosted: Thu Jan 29, 2004 4:32 pm    Post subject: Re: Convert a String to a Stream Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.