Board index » delphi » printing multiple bmps to a printer canvas (using printbitmap) prints out B+W

printing multiple bmps to a printer canvas (using printbitmap) prints out B+W

Hi

I am using the 'preferred method' for printing bmps, that is, using the
printbitmap from EFG's computer page.

I use it to print mutliple images on a printed page, with the following
code (summarised)

printer.begindoc

loop though all images in a list doing:
load bitmap
determine bmprect
printbitmap(printer.canvas, bmprect, loadedbmp);

printer.enddoc.

It works fine except on colour printers where it always comes out in
greyscale NOT colour.  It is not just the printer as i have tested it on
three different computers with the same result on all.

ANy suggestions on where i might be going wrong or what i might try would
be greatly appreciated.

Thanks

William
nospam.the_white_ho...@usa.net (remove nospam. when e-mailing)

 

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


The driver might be configured to print grey scale, but it is probably
trying to autodetect when color is used (to conserve colored ink).
You might try a hack like drawing a line with a colored pen outside
the printable area of the page.  If that doesn't work, try something
similar.  The basic idea is to trick the driver into switching to
color.

On 19 Feb 1999 22:06:01 GMT, "William"

Quote
<nospam.the_white_ho...@usa.net> wrote:
>It works fine except on colour printers where it always comes out in
>greyscale NOT colour.  It is not just the printer as i have tested it on
>three different computers with the same result on all.

Chris Hill
Chris...@aol.com

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


Generally, no special effort is required to print in color assuming the
printer is
a color printer and is set to it's native color mode. Windows will
automatically
convert color to black and white if the printer does not support color.
If you need
to change the color mode in code, you can access the DevMode structure
of the
printer driver.

Example:

uses Printers;

procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin
      pDMode^.dmFields := pDMode^.dmFields or dm_Color;
      pDMode^.dmColor := DMCOLOR_COLOR;
      GlobalUnlock(hDMode);
    end;
  end;
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.BeginDoc;
  Printer.Canvas.Font.Color := clRed;
  Printer.Canvas.TextOut(100,100, 'Red As A Rose!');
  Printer.EndDoc;
end;

Joe
--
Joe C. Hecht
http://home1.gte.net/joehecht/index.htm

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


Quote
William wrote in message <01be5c55$17429e50$1c6c60cb@npc_1>...
>It works fine except on colour printers where it always comes out in
>greyscale NOT colour.  It is not just the printer as i have tested it on
>three different computers with the same result on all.

You might try the "Slide Show" utility to print the images
www.efg2.com/lab/ImageProcessing/SlideShow.htm

This utility uses the same code you're referencing.

I've used this utility to print 100 or more images on a single page, either in color or black and white.

There are differences among various printers, but a color image should print in color.

efg

_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


Thank you both for your suggestions.  I will try this.

I have found that it works fine when the windows display is set to 16 bit
colour or greater, ot only does B+W if it is set to 256 colours.

William

Joe C. Hecht <joehe...@gte.net> wrote in article <36CE00E6.2...@gte.net>...

Quote
> Generally, no special effort is required to print in color assuming the
> printer is
> a color printer and is set to it's native color mode. Windows will
> automatically
> convert color to black and white if the printer does not support color.
> If you need
> to change the color mode in code, you can access the DevMode structure
> of the
> printer driver.

> Example:

> uses Printers;

> procedure TForm1.Button1Click(Sender: TObject);
> var
> Device : array[0..255] of char;
> Driver : array[0..255] of char;
> Port   : array[0..255] of char;
> hDMode : THandle;
> PDMode : PDEVMODE;
> begin
>   Printer.PrinterIndex := Printer.PrinterIndex;
>   Printer.GetPrinter(Device, Driver, Port, hDMode);
>   if hDMode <> 0 then begin
>     pDMode := GlobalLock(hDMode);
>     if pDMode <> nil then begin
>       pDMode^.dmFields := pDMode^.dmFields or dm_Color;
>       pDMode^.dmColor := DMCOLOR_COLOR;
>       GlobalUnlock(hDMode);
>     end;
>   end;
>   Printer.PrinterIndex := Printer.PrinterIndex;
>   Printer.BeginDoc;
>   Printer.Canvas.Font.Color := clRed;
>   Printer.Canvas.TextOut(100,100, 'Red As A Rose!');
>   Printer.EndDoc;
> end;

> Joe
> --
> Joe C. Hecht
> http://home1.gte.net/joehecht/index.htm

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


Quote
William wrote:

> Thank you both for your suggestions.  I will try this.

> I have found that it works fine when the windows display is set to 16 bit
> colour or greater, ot only does B+W if it is set to 256 colours.

Hard to believe, but the Windows GDI and the Printer driver may
use the video driver for raster services.
Joe
--
Joe C. Hecht
http://home1.gte.net/joehecht/index.htm

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


the printbitmap function, does it use DIBs or DDBs?
Davie
Quote
William wrote:
> Hi

> I am using the 'preferred method' for printing bmps, that is, using the
> printbitmap from EFG's computer page.

> I use it to print mutliple images on a printed page, with the following
> code (summarised)

> printer.begindoc

> loop though all images in a list doing:
> load bitmap
> determine bmprect
> printbitmap(printer.canvas, bmprect, loadedbmp);

> printer.enddoc.

> It works fine except on colour printers where it always comes out in
> greyscale NOT colour.  It is not just the printer as i have tested it on
> three different computers with the same result on all.

> ANy suggestions on where i might be going wrong or what i might try would
> be greatly appreciated.

> Thanks

> William
> nospam.the_white_ho...@usa.net (remove nospam. when e-mailing)

Re:printing multiple bmps to a printer canvas (using printbitmap) prints out B+W


Ok, try this, take a 256 or less color GIF or bitmap and then try printing it
and see if it prints in color WHILE IN 256 Video mode!
Davie
Quote
William wrote:
> Thank you both for your suggestions.  I will try this.

> I have found that it works fine when the windows display is set to 16 bit
> colour or greater, ot only does B+W if it is set to 256 colours.

> William

> Joe C. Hecht <joehe...@gte.net> wrote in article <36CE00E6.2...@gte.net>...
> > Generally, no special effort is required to print in color assuming the
> > printer is
> > a color printer and is set to it's native color mode. Windows will
> > automatically
> > convert color to black and white if the printer does not support color.
> > If you need
> > to change the color mode in code, you can access the DevMode structure
> > of the
> > printer driver.

> > Example:

> > uses Printers;

> > procedure TForm1.Button1Click(Sender: TObject);
> > var
> > Device : array[0..255] of char;
> > Driver : array[0..255] of char;
> > Port   : array[0..255] of char;
> > hDMode : THandle;
> > PDMode : PDEVMODE;
> > begin
> >   Printer.PrinterIndex := Printer.PrinterIndex;
> >   Printer.GetPrinter(Device, Driver, Port, hDMode);
> >   if hDMode <> 0 then begin
> >     pDMode := GlobalLock(hDMode);
> >     if pDMode <> nil then begin
> >       pDMode^.dmFields := pDMode^.dmFields or dm_Color;
> >       pDMode^.dmColor := DMCOLOR_COLOR;
> >       GlobalUnlock(hDMode);
> >     end;
> >   end;
> >   Printer.PrinterIndex := Printer.PrinterIndex;
> >   Printer.BeginDoc;
> >   Printer.Canvas.Font.Color := clRed;
> >   Printer.Canvas.TextOut(100,100, 'Red As A Rose!');
> >   Printer.EndDoc;
> > end;

> > Joe
> > --
> > Joe C. Hecht
> > http://home1.gte.net/joehecht/index.htm

Other Threads