Article View: borland.public.cppbuilder.nativeapi
Article #1454Re: quick data copy between objects
From: Remy Lebeau (TeamB)
Date: Wed, 01 Aug 2007 22:16
Date: Wed, 01 Aug 2007 22:16
39 lines
2845 bytes
2845 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message news:46b0f5c4$1@newsgroups.borland.com... > I've got a timing/performance need... I'm trying to capture > the screen as BMP, compress to JPG, then send over a > TCustomWinSocket. I'm afraid it just takes too long... :( You are sending the entire image in full each time. If you are trying to implement some kind of real-time video capture of the screen, then you should be sending deltas instead. Capture the full image once, send it, then send only what has changed since the last transmission. The receiver can then overlay the deltas on top of each other when they are received. If very little changes, then there will be very few transmissions, and you can probably do away with the JPG conversion altogether (which isn't a good way to compress BMP anyway since JPG is a lossy format). > // send image data to client > SocketOut->SendBuf(WriteStream->Memory, WriteStream->Size); You are not sending the stream size to the client, so it won't know how many bytes it needs to read for each image. > // reset stream for next use > WriteStream->Clear(); If you are sending images of the same dimensions each time, then you don't really need to Clear() the stream each time, since the image data is likely to be the same size the next time around. Using Clear() will waste time allocating and freeing the memory over and over. You could simply reset the Position back to 0, leaving the memory intact. The next time you save an image to the stream, it will overwrite the contents that are already present. Since you would start the Position at 0, you could use the Position to know how many bytes were actually saved, rather than relying on the Size property. This way, smaller images can reuse the same stream memory, and larger images will grow the memory when needed. Gambit
Technical Details
Message-ID:
<46b1068a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46b0f5c4$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2f02e67f1be3ea63 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <46b0f5c4$1@newsgroups.borland.com> Subject: Re: quick data copy between objects Date: Wed, 1 Aug 2007 15:16:59 -0700 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.29.61 Message-ID: <46b1068a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1186006666 75.83.29.61 (1 Aug 2007 15:17:46 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail