Board index » delphi » Printing with Canvas.LineTo

Printing with Canvas.LineTo

Hi there,

Is there anyway to print a Line on the printer canvas so that it prints in
grayscale.
The brush seems to work ok but the line always prints out in black...
Am i missing somthing?

TIA,

Graham Murt

 

Re:Printing with Canvas.LineTo


Quote
"Graham Murt" <gra...@murtsoft.com> wrote in message news:3ac4785b$1_2@dnews...
> Is there anyway to print a Line on the printer canvas so that it prints in
> grayscale.

I see a few (perhaps 3) shades of gray (namely, black, gray, white) with this
on an Epson Color Stylus 850:

USES
  Printers;

procedure TForm1.Button1Click(Sender: TObject);
  VAR
    j:  INTEGER;
begin
  Printer.BeginDoc;
  TRY
    FOR j := 0 TO 63 DO
    BEGIN
      Printer.Canvas.Pen.Color := RGB(4*j, 4*j, 4*j);
      Printer.Canvas.MoveTo( 100, 20*j);    // assume 600+ DPI
      Printer.Canvas.LineTo(2500, 20*j);    // approx 4" long line
    END
  FINALLY
    Printer.EndDoc
  END
end;

For any given printer, you just have to run an experiment like
above and see what you get.  If you don't get the desired shades
of gray, try creating an in-memory pf24bit bitmap and drawing
everything on it.  The use StretchDIBits to print the resulting
bitmap.
http://homepages.borland.com/efg2lab/Library/Delphi/Printing/Default....

If StretchDIBits fails, then try
Joe Hecht's TExcellentImagePrinter
http://www.code4sale.com/joehecht/prndib.htm

--
efg     e...@efg2.com     Earl F. Glynn, Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab
Mirror:  http://homepages.borland.com/efg2lab/Default.htm

Re:Printing with Canvas.LineTo


Is there any way, other than copying to Bitmaps and drawing the bitmaps to
the printer canvas, of drawing lines in any shade?

MS Word allows you to draw lines of any shade which are printed through a
laser printer in the right dithering/shade... anyone know how this is done?

Thanks Earl and anyone else who can help.

Graham

"Earl F. Glynn" <EarlGl...@att.net> wrote in message
news:3ac49e42$1_2@dnews...

Quote
> "Graham Murt" <gra...@murtsoft.com> wrote in message

news:3ac4785b$1_2@dnews...
Quote

> > Is there anyway to print a Line on the printer canvas so that it prints
in
> > grayscale.

> I see a few (perhaps 3) shades of gray (namely, black, gray, white) with
this
> on an Epson Color Stylus 850:

> USES
>   Printers;

> procedure TForm1.Button1Click(Sender: TObject);
>   VAR
>     j:  INTEGER;
> begin
>   Printer.BeginDoc;
>   TRY
>     FOR j := 0 TO 63 DO
>     BEGIN
>       Printer.Canvas.Pen.Color := RGB(4*j, 4*j, 4*j);
>       Printer.Canvas.MoveTo( 100, 20*j);    // assume 600+ DPI
>       Printer.Canvas.LineTo(2500, 20*j);    // approx 4" long line
>     END
>   FINALLY
>     Printer.EndDoc
>   END
> end;

> For any given printer, you just have to run an experiment like
> above and see what you get.  If you don't get the desired shades
> of gray, try creating an in-memory pf24bit bitmap and drawing
> everything on it.  The use StretchDIBits to print the resulting
> bitmap.

http://homepages.borland.com/efg2lab/Library/Delphi/Printing/Default....
ntBitmap

- Show quoted text -

Quote

> If StretchDIBits fails, then try
> Joe Hecht's TExcellentImagePrinter
> http://www.code4sale.com/joehecht/prndib.htm

> --
> efg     e...@efg2.com     Earl F. Glynn, Overland Park, KS  USA

> efg's Computer Lab:  http://www.efg2.com/Lab
> Mirror:  http://homepages.borland.com/efg2lab/Default.htm

Other Threads