Board index » delphi » printer.canvas.rectangle not working on NT

printer.canvas.rectangle not working on NT

The following code prints a shaded box on Win95/98, but on NT4:

printer.canvas.brush.style := bsBDiagonal;
printer.canvas.brush.color := clBlack;
printer.canvas.rectangle(20,x,printer.pagewidth,x+LH);

If I use BsSolid style, I get a black box. So bsBDiagonal does not
work on NT. Any ideas on what I can do to print a shaded box on NT4? I
am using Delphi4. I have read this whole forum and all the tech.
papers. I am stumped, please help.

Many thanks,
Mike
m...@mrtec.com

 

Re:printer.canvas.rectangle not working on NT


Quote
Michael Raustad wrote:

> The following code prints a shaded box on Win95/98, but on NT4:

> printer.canvas.brush.style := bsBDiagonal;
> printer.canvas.brush.color := clBlack;
> printer.canvas.rectangle(20,x,printer.pagewidth,x+LH);

> If I use BsSolid style, I get a black box. So bsBDiagonal does not
> work on NT. Any ideas on what I can do to print a shaded box on NT4? I
> am using Delphi4. I have read this whole forum and all the tech.
> papers. I am stumped, please help.

I have an answer for you Michael, but you might not like it!

Brushes are not very device dependent. In theroy, those diagonal
lines in the shading pattern are one pixel thick, spaced every
eight pixels. On a hires device, the eye just cant see one pixel
very well, and the eye blends it all together and you see black.

With some devices, there are additional issues such as "dot spead"
and the paper changing size due to very fast changes in tempature
and humidity that also factors into the black square you are seeing.

Some printer drivers (very rare) have enough smarts to see that
bsDiagonal brush comming, and substitute something that looks more
reasonable, even if it's not what the operating system said to do.
This is the reason by it might look better on 95, but only when
using the the driver you are using.

For good "all across the board" results, your going to have to
draw your own device independent hatching pattern :(

Note that this *not* an issue with Delphi, but rather (IMHO)
a large oversight made by the designers of the Windows GDI.

Hope that helps!

Joe
--
Joe C. Hecht
joehe...@gte.net
(850) 689-0877 121 Louise Dr. Crestview, FL 32536
http://home1.gte.net/joehecht/index.htm

Re:printer.canvas.rectangle not working on NT


Quote
Joe C. Hecht wrote in message <364B9BCE.3...@gte.net>...
>For good "all across the board" results,
>your going to have to draw your own device
>independent hatching pattern :(

Joe, I appreciate your reply! Maybe I will have to do that, however, I
am having a hard believing WinNT does not have an API call to do
shading. <G> By your reply I take it to mean that there are not any NT
apps that can do shading without implementing their own routines,
correct? If so, I agree, NT lost their way somewhere.

Best regards,
Mike

Re:printer.canvas.rectangle not working on NT


Quote
Michael Raustad wrote:

> Joe C. Hecht wrote in message <364B9BCE.3...@gte.net>...
> >For good "all across the board" results,
> >your going to have to draw your own device
> >independent hatching pattern :(

> Joe, I appreciate your reply! Maybe I will have to do that, however, I
> am having a hard believing WinNT does not have an API call to do
> shading. <G> By your reply I take it to mean that there are not any NT
> apps that can do shading without implementing their own routines,
> correct? If so, I agree, NT lost their way somewhere.

Well Mike, it depend on what you mean by shading. You can use simulated
gray shades on a monochrome printer, but be forwarded that 50% black
may or may not really translate optically to 50% black<g>. If your
taking about hatching patterens, then yes, you will need to draw your
own patterns. A hatched line is not to difficult to draw. What you
really want is to draw the lines some finite distance apart, for
instance every 1/8th of an inch. The hatched brush draws them
every 8 pixels. This may look good on a 96 dpi display, but will
look pretty bad at 300 dpi, even worse at 600 dpi, and absolutly
terrible at 3600 dpi on film.

Another point to make. You line with should be scaled to some finite
measurment. A pen width of one pixel on a 3600 dpiu device cannot
even be seen with the {*word*192} eye. The same is almost true at 600 dpi,
where a pen width of one is 1/600th inch wide. Better get you glasses
or a good high powered lupe to see something like that!

Joe
--
Joe C. Hecht
joehe...@gte.net
(850) 689-0877 121 Louise Dr. Crestview, FL 32536
http://home1.gte.net/joehecht/index.htm

Re:printer.canvas.rectangle not working on NT


On Thu, 12 Nov 1998 22:14:58 -0500, "Michael Raustad" <m...@mrtec.com>
wrote:

Quote
>Joe, I appreciate your reply! Maybe I will have to do that, however, I
>am having a hard believing WinNT does not have an API call to do
>shading. <G> By your reply I take it to mean that there are not any NT
>apps that can do shading without implementing their own routines,
>correct? If so, I agree, NT lost their way somewhere.

I think Joe meant that is it a driver issue.

If you can't get the diagonal lines to work, you can use a bitmap
brush instead.  The bitmap can contain a diagonal line pattern of your
own design (possibly based on the resolution of the target device).
On Win9x, you are limited to an 8x8 bitmap, but NT allows large
bitmaps to be used. A large bitmap might be required to produce
acceptable results (line spacing) on a high resolution device, so this
might be an NT only solution.  This method would be device independent
(unless there are bugs in the printer driver...)

Chris Hill
hil...@cs.purdue.edu

Re:printer.canvas.rectangle not working on NT


Michael,

I've been looking into the same issue. If all you want is shading, then
experiment with colors. If you want a patterned fill to the rectangle...

With my Brother HL630, Red, Blue and Cyan produce three distinguishable
grays.

If you overlap two rectangles, fill one with a solid brush and one with
a diagonal brush, the diagonal lines show white in the overlapped area!
It looks like the fill is being done with an XOR?

Quote
Michael Raustad wrote:

> The following code prints a shaded box on Win95/98, but on NT4:

> printer.canvas.brush.style := bsBDiagonal;
> printer.canvas.brush.color := clBlack;
> printer.canvas.rectangle(20,x,printer.pagewidth,x+LH);

> If I use BsSolid style, I get a black box. So bsBDiagonal does not
> work on NT. Any ideas on what I can do to print a shaded box on NT4? I
> am using Delphi4. I have read this whole forum and all the tech.
> papers. I am stumped, please help.

> Many thanks,
> Mike
> m...@mrtec.com

--
Ken Bailey
Falmouth Software Works Ltd.

Other Threads