Article View: borland.public.cppbuilder.nativeapi
Article #7120Re: Printing Speed
From: Bob Gonder
Date: Sat, 12 Mar 2005 20:42
Date: Sat, 12 Mar 2005 20:42
75 lines
4220 bytes
4220 bytes
JD wrote: >After using the VCL for a while, you get familure with >working with a TCanvas and the TPrinter has a TCanvas so >printing uses the same functions that one would use draw text >on a control or a graph in a bitmap. A Canvas is a DC. You just use DC methods. BitBlt, StretchBlt, TextOut, etc, See the Win32.hlp topics starting at "Printer Device Contexts Overview" Also: "Bitmaps, Device Contexts, and Drawing Surfaces" > It also has functions >that draw shapes and lines and copies blocks of pixels from >one Canvas to another See Clipping Functions and BeginPath() >. Once the Canvas is set, you print it by >using NewPage or EndDoc. Same. >See, the thing that got me starting this thread was a test >that I did. I generated a bitmap that had text and a pic and >printed that using TPrinter::Canvas. When I put the litteral >text into WordPad and added the pic, it printed slower than >the Canvas test. Well, what did you expect from an MS program, speed? >Without the pic, they print about the same so I'm assuming >that WordPad could be better optimized when printing graphics >(and that bandwith has nothing to do with it). So ... if one >print method can be faster than another, then why can't there >be another, faster method and how do I know when I've maxed it >out? You'll never know. We quit trying when it is "fast enough", or at least, as fast as we can figure how to make it. Later, someone will show us a faster way, and so we adopt it. We don't notice when newer/faster fails to come along. Just look at all the attempts at a FastMath library. (And how different methods are faster on different processors.) One thing I can tell you without reservation, is the VCL is going to execute slower than direct coding. A call to a thin API wrapper is an extra CPU pipeline flush, and is going to slow things down. Of course, with the physical slowness of putting the dots on the paper, you shouldn't notice it much. In any case, pure Win32 API should in theory be at least as fast as VCL. It might be faster if the VCL does things that aren't needed by your particular application, or are redundant. (If you look at the ASM generated by a C program, there are lots of redundant loads, which an ASM programmer can optimise out. There might be similar happenings in VCL generated code.) Look at the VCL functions you are using, what they are doing under-the-hood, and see if you can figure a simpler method or eliminate some of the internal steps. IIRC, the TCanvas has a DC property that you can use the API drawing functions on. So use TPrinter for selection/setup and NewPage, but API for drawing on the canvas. The only speed boost I can think of right now is to align your BitBlts so they start on whole bytes (dwords?) instead of half-a-byte. That makes for blocky placement, but if you plan ahead for it, maybe the BMP image could be pre-adjusted with whitespace to the left/right. To get much faster, you'd probably need to drop to ASM, and rewrite/replace the BitBlt et.al. funtions.
Technical Details
Message-ID:
<hph6319bg4vd6abaeq9mkt1qr1ia738o7u@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<422e0600$1@newsgroups.borland.com> <422e069d$1@newsgroups.borland.com> <nh9u21dnhu891k0ntan3rfscafc68deda1@4ax.com> <42313c84$1@newsgroups.borland.com> <4lf331dp7gsqvddkdr59j67nbkiehib3il@4ax.com> <4232d5c7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,eee7bb1b529382b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Printing Speed Date: Sat, 12 Mar 2005 12:42:10 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <hph6319bg4vd6abaeq9mkt1qr1ia738o7u@4ax.com> References: <422e0600$1@newsgroups.borland.com> <422e069d$1@newsgroups.borland.com> <nh9u21dnhu891k0ntan3rfscafc68deda1@4ax.com> <42313c84$1@newsgroups.borland.com> <4lf331dp7gsqvddkdr59j67nbkiehib3il@4ax.com> <4232d5c7$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.146.42 X-Trace: newsgroups.borland.com 1110660128 67.77.146.42 (12 Mar 2005 12:42:08 -0800) Lines: 79 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail